This commit is contained in:
IGNY8 VPS (Salman)
2025-11-16 20:02:45 +00:00
parent 9f3c4a6cdd
commit b2e60b749a
3 changed files with 283 additions and 23 deletions

View File

@@ -67,16 +67,10 @@ class JWTAuthentication(BaseAuthentication):
try:
account = Account.objects.get(id=account_id)
except Account.DoesNotExist:
pass
if not account:
try:
account = getattr(user, 'account', None)
except (AttributeError, Exception):
# If account access fails, set to None
# Account from token doesn't exist - don't fallback, set to None
account = None
# Set account on request
# Set account on request (only if account_id was in token and account exists)
request.account = account
return (user, token)