Skip to content

Commit

Permalink
feat: use __dict__ when caching the data
Browse files Browse the repository at this point in the history
  • Loading branch information
helllllllder committed Oct 17, 2024
1 parent cb2d505 commit 0947921
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions chats/apps/accounts/authentication/drf/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ def __init__(
self.user_first_name = user_first_name
self.role = role

def __dict__(self) -> dict:
return {
"pk": self.pk,
"project": self.project,
"user_email": self.user_email,
"role": self.role,
}


class ProjectAdminAuthentication(TokenAuthentication):
keyword = "Bearer"
Expand Down Expand Up @@ -88,6 +80,6 @@ def authenticate_credentials(self, key):
return (authorization.user_email, authorization)

authorization = self._authenticate_credentials(key)[1]
redis_connection.set(key, json.dumps(dict(authorization)), self.cache_ttl)
redis_connection.set(key, json.dumps(authorization.__dict__), self.cache_ttl)

return (authorization.user_email, authorization)

0 comments on commit 0947921

Please sign in to comment.