Do not flush session on sudo to default account#3575
Merged
johannaengland merged 1 commit intoUninett:5.14.xfrom Oct 15, 2025
Merged
Do not flush session on sudo to default account#3575johannaengland merged 1 commit intoUninett:5.14.xfrom
johannaengland merged 1 commit intoUninett:5.14.xfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 5.14.x #3575 +/- ##
=======================================
Coverage 61.44% 61.44%
=======================================
Files 610 610
Lines 44726 44726
Branches 43 43
=======================================
Hits 27480 27480
Misses 17236 17236
Partials 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The default account is usually marked as locked since it has no password
972f6d2 to
d8a79e9
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Scope and purpose
Fixes #3571.
The function
ensure_accountchecks if the account is locked and if so flushes the session and changes to the default account. #2828 added the session flushing. The problem is that the default account is usually marked as locked since it has no password.So before this function introduced the session flushing when sudoing to the default user this function always set the the current user (default account) to default account, so in essence no difference, but a silly thing that was introduced much earlier in 2019 in #2007.
But after the session flushing was added this leads to the information about the sudoing user that is saved in the session under
session[SUDOER_ID_VAR]to be deleted, which means that the sudoing user is essentially logged out.Contributor Checklist
Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.
<major>.<minor>.x). For a new feature or other additions, it should be based onmaster.