diff options
author | 2024-07-17 12:10:25 +0100 | |
---|---|---|
committer | 2024-07-17 22:16:19 +0100 | |
commit | 46af39a2a3286401f87a92b3f488bd8b67184c05 (patch) | |
tree | 9fda172c7f8f30795866659d29e14ba74465b31e /backend/authentication | |
parent | Simplify the logic for fetching from member cache (diff) |
Use redis to store the role cache
Diffstat (limited to 'backend/authentication')
-rw-r--r-- | backend/authentication/backend.py | 2 | ||||
-rw-r--r-- | backend/authentication/user.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/backend/authentication/backend.py b/backend/authentication/backend.py index c84ba10..e150580 100644 --- a/backend/authentication/backend.py +++ b/backend/authentication/backend.py @@ -68,6 +68,6 @@ class JWTAuthenticationBackend(authentication.AuthenticationBackend): if await user.fetch_admin_status(request.state.db): scopes.append("admin") - scopes.extend(await user.get_user_roles(request.state.db)) + scopes.extend(await user.get_user_roles()) return authentication.AuthCredentials(scopes), user diff --git a/backend/authentication/user.py b/backend/authentication/user.py index ad59103..5e99546 100644 --- a/backend/authentication/user.py +++ b/backend/authentication/user.py @@ -44,12 +44,12 @@ class User(BaseUser): def decoded_token(self) -> dict[str, any]: return jwt.decode(self.token, SECRET_KEY, algorithms=["HS256"]) - async def get_user_roles(self, database: Database) -> list[str]: + async def get_user_roles(self) -> list[str]: """Get a list of the user's discord roles.""" if not self.member: return [] - server_roles = await discord.get_roles(database) + server_roles = await discord.get_roles() roles = [role.name for role in server_roles if role.id in self.member.roles] if "admin" in roles: |