fix(users): a password reset signs out every session begun with the old password (#5427)
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 1m7s
CI / unit (push) Failing after 1m24s
CI / publish (push) Skipped

#5427 "A password reset doesn't end the sessions already signed in with
the old password": users.sessions_since (migration 0038) is set on reset;
refresh_session_user ends a session whose login_at is earlier. An admin
resetting their own password carries on signed in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 17:25:35 -04:00
co-authored by Claude Opus 5.5
parent fb4cf098c3
commit 2995cfdd68
7 changed files with 66 additions and 3 deletions
+4
View File
@@ -145,6 +145,10 @@ async def refresh_session_user() -> None:
if user is None or not user.is_active:
session.clear()
return
# The password was reset after this session began (#5427).
if user.sessions_since is not None and started < user.sessions_since.timestamp():
session.clear()
return
if session.get("user_role") != user.role.value:
session["user_role"] = user.role.value
# The zone times are written in (milestone 490): a change made on the