mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-28 03:17:32 +00:00
fix: Overwrite previous access token on non-retry refreshes
Previously, set_token skipped saving the replaced access token whenever a previous token entry already existed. If a client refreshed again with its current refresh token before making a valid API request (such as after going idle until expiry), a dropped response would leave the server holding an older access token and cause a hard logout. Let callers explicitly specify whether to clear, replace, or preserve the previous access token.
This commit is contained in:
4 files changed
+44
-12
No files matched your search
@@ -28,7 +28,7 @@ use ruma::{
|
||||
},
|
||||
assign,
|
||||
};
|
||||
use service::users::DeviceToken;
|
||||
use service::users::{DeviceToken, PreviousTokenAction};
|
||||
|
||||
use crate::{Ruma, client_ip::ClientIp};
|
||||
|
||||
@@ -205,7 +205,7 @@ pub(crate) async fn login_route(
|
||||
let device_id = if let Some(existing_device_id) = existing_device_id {
|
||||
services
|
||||
.users
|
||||
.set_token(&user_id, &existing_device_id, token.clone())
|
||||
.set_token(&user_id, &existing_device_id, token.clone(), PreviousTokenAction::Clear)
|
||||
.await?;
|
||||
|
||||
existing_device_id
|
||||
|
||||
Reference in new issue
Block a user