TASK-002 Enforce authorization and media boundaries

This commit is contained in:
rob
2026-11-25 17:24:12 +00:00
parent cd6d6b3a83
commit 549f11d9f4
14 changed files with 374 additions and 92 deletions
+5 -2
View File
@@ -16,10 +16,11 @@ basic_auth.realm = "Incorrect Credentials"
def get_token():
"""Get token."""
user = basic_auth.current_user()
user.get_token()
refresh_token = user.get_refresh_token()
db.session.commit()
response = make_response(
jsonify(user.to_dict(rules=("is_admin", "token")))
jsonify({**user.to_dict(rules=("is_admin", "token")), "user_id": user.id})
)
response.set_cookie("refresh_token", value=refresh_token, httponly=True)
return response
@@ -41,10 +42,12 @@ def refresh_token():
if refresh_token is None:
return error_response(400, "Bad request, no refresh token")
user = User.query.filter_by(refresh_token=refresh_token).first()
if user is not None:
if user is not None and user.login_disabled is False:
access_token = user.get_token()
db.session.commit()
return {
"token": access_token,
"user_id": user.id,
}
return error_response(401)