diff options
author | 2022-03-20 17:25:06 -0400 | |
---|---|---|
committer | 2022-03-20 17:25:06 -0400 | |
commit | 25fce5e0161c2d84d4a6b710aa5c83a863766f98 (patch) | |
tree | e3c15dad453f8d518bbf5335a14eddedf2c2d054 /backend/authentication/backend.py | |
parent | Merge pull request #151 from python-discord/dependabot/pip/sentry-sdk-1.5.7 (diff) | |
parent | Merge branch 'main' into roles (diff) |
Merge pull request #135 from python-discord/roles
Overhaul Access System
Diffstat (limited to 'backend/authentication/backend.py')
-rw-r--r-- | backend/authentication/backend.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/backend/authentication/backend.py b/backend/authentication/backend.py index c7590e9..54385e2 100644 --- a/backend/authentication/backend.py +++ b/backend/authentication/backend.py @@ -5,6 +5,7 @@ from starlette import authentication from starlette.requests import Request from backend import constants +from backend import discord # We must import user such way here to avoid circular imports from .user import User @@ -60,8 +61,12 @@ class JWTAuthenticationBackend(authentication.AuthenticationBackend): except Exception: raise authentication.AuthenticationError("Could not parse user details.") - user = User(token, user_details) - if await user.fetch_admin_status(request): + user = User( + token, user_details, await discord.get_member(request.state.db, user_details["id"]) + ) + if await user.fetch_admin_status(request.state.db): scopes.append("admin") + scopes.extend(await user.get_user_roles(request.state.db)) + return authentication.AuthCredentials(scopes), user |