fix: Serialize OAuth session mutations per device

Concurrent token refreshes or API requests clearing the previous refresh
token could overwrite userdeviceid_oauthsessioninfo with stale session
state or leave orphaned entries in refreshtoken_refreshtokeninfo.

Guard session mutations with a per-device MutexMap and re-read session
info under the lock when clearing the previous refresh token.
This commit is contained in:
Jade Ellis committed 2026-11-27 18:41:45 +00:00
1 parent 6412a650a5
commit ef24867786
2 files changed
+44 -18

No files matched your search

+8 -6
View File
@@ -324,12 +324,14 @@ async fn check_access_token(
.get_session_info_for_device(&sender_user, &sender_device)
.await;
if let Some(session_info) = &session_info {
services.oauth.clear_previous_refresh_token(
&sender_user,
&sender_device,
session_info,
);
if session_info
.as_ref()
.is_some_and(|info| info.has_previous_refresh_token())
{
services
.oauth
.clear_previous_refresh_token(&sender_user, &sender_device)
.await;
}
// Locked users can only use /logout and /logout/all