aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/auth
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-11-14 01:56:46 +0000
committerGravatar Joe Banks <[email protected]>2020-11-14 01:56:46 +0000
commite9b55908e1fc12551b57bb9708d80c5c6774c251 (patch)
tree888473df4633b7346c8bfeedc8249a7a2fae0c0a /backend/routes/auth
parentAdd schema file describing feature meanings (diff)
Check if a user is an admin in the token payload
Diffstat (limited to 'backend/routes/auth')
-rw-r--r--backend/routes/auth/authorize.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/backend/routes/auth/authorize.py b/backend/routes/auth/authorize.py
index 0a90856..768b9af 100644
--- a/backend/routes/auth/authorize.py
+++ b/backend/routes/auth/authorize.py
@@ -24,6 +24,10 @@ class AuthorizeRoute(Route):
bearer_token = await fetch_bearer_token(data["token"])
user_details = await fetch_user_details(bearer_token["access_token"])
+ user_details["admin"] = request.state.db.admins.find_one(
+ {"_id": user_details["id"]}
+ ) is not None
+
token = jwt.encode(user_details, SECRET_KEY, algorithm="HS256")
return JSONResponse({