-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iss2205 #2355
base: main
Are you sure you want to change the base?
Iss2205 #2355
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
Please check the formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naturally, a test would be nice : )
Thanks!
@@ -52,6 +52,9 @@ def is_in_staff_mode(request): | |||
|
|||
|
|||
def update_staff_mode(request): | |||
if not request.user.has_staff_permission: | |||
exit_staff_mode(request) | |||
return | |||
assert request.user.has_staff_permission |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this assertion is no longer needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move it up to line 33, where I think it would still add value.
The call graphs we can get now are a bit wonky. We can have
enter_staff_mode
-> update_staff_mode
-> finds out that not request.user.has_staff_permission
-> exit_staff_mode
and returns without exception, which is probably never what the initial caller intended?
It seems to me that update_staff_mode
was about "update the timestamp in the session to now()" in the past, now it has changed semantics. Could use a little clean up in general, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking for missing test, since this is authorization logic and we discovered a code path in the issue that we considered not to happen naturally before. Feel free to assign the PR to me if you want me to write the test.
fix #2205