Skip to content

Commit

Permalink
Merge pull request #2836 from stveit/let_set_account_handle_session_m…
Browse files Browse the repository at this point in the history
…anip

Do not manipulate session in ensure_account
  • Loading branch information
stveit committed Feb 29, 2024
2 parents 0fe59ef + 3871c37 commit 9f8214e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions python/nav/web/auth/utils.py
Expand Up @@ -47,10 +47,8 @@ def ensure_account(request):
"""Guarantee that valid request.account is set"""
session = request.session

if not ACCOUNT_ID_VAR in session:
session[ACCOUNT_ID_VAR] = Account.DEFAULT_ACCOUNT

account = Account.objects.get(id=session[ACCOUNT_ID_VAR])
account_id = session.get(ACCOUNT_ID_VAR, Account.DEFAULT_ACCOUNT)
account = Account.objects.get(id=account_id)

if account.locked:
# Switch back to fallback, the anonymous user
Expand Down

0 comments on commit 9f8214e

Please sign in to comment.