Revert "Fix authentication: Ensure correct user/account is loaded"
This reverts commit a267fc0715.
This commit is contained in:
@@ -55,9 +55,7 @@ class JWTAuthentication(BaseAuthentication):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Refresh user from DB with account and plan relationships to get latest data
|
user = User.objects.get(id=user_id)
|
||||||
# This ensures changes to account/plan are reflected immediately without re-login
|
|
||||||
user = User.objects.select_related('account', 'account__plan').get(id=user_id)
|
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
# User not found - return None to allow other auth classes to try
|
# User not found - return None to allow other auth classes to try
|
||||||
return None
|
return None
|
||||||
@@ -68,12 +66,7 @@ class JWTAuthentication(BaseAuthentication):
|
|||||||
if account_id:
|
if account_id:
|
||||||
try:
|
try:
|
||||||
account = Account.objects.get(id=account_id)
|
account = Account.objects.get(id=account_id)
|
||||||
# If user's account changed, use the new one from user object (most up-to-date)
|
|
||||||
# This ensures we always use the user's current account, not a stale token account_id
|
|
||||||
if user.account and user.account.id != account_id:
|
|
||||||
account = user.account
|
|
||||||
except Account.DoesNotExist:
|
except Account.DoesNotExist:
|
||||||
# Account from token doesn't exist - use user's account instead
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not account:
|
if not account:
|
||||||
|
|||||||
Reference in New Issue
Block a user