Skip to content

Commit

Permalink
Add func for clearing session
Browse files Browse the repository at this point in the history
takes a request and clears everything session related from it
  • Loading branch information
stveit committed Mar 1, 2024
1 parent 459cb29 commit 1bca3ac
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/nav/web/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def set_account(request, account, cycle_session_id=True):
request.session.save()


def clear_session(request):
"""Clears the session and logs out the current account"""
del request.account
request.session.flush()
request.session.save()


def ensure_account(request):
"""Guarantee that valid request.account is set"""
session = request.session
Expand Down

0 comments on commit 1bca3ac

Please sign in to comment.