mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-23 14:10:42 -05:00
fix: automatic SSO sign-in fails with a state mismatch after the session expires (#33791)
With OAUTH_AUTO_REDIRECT on, an expired or invalid session sent the browser to the identity provider while the sign-out request was still running. When that request finished it wiped the login state, so the callback failed and the user landed on the sign-in page with an error. The sign-out now completes before the redirect, so the user is signed back in without an error. Fixes #33783
This commit is contained in:
1 parent
8ebc96d3d8
commit
2fb2e9ea27
1 file changed
+5
-4
@@ -1024,7 +1024,7 @@
|
||||
}
|
||||
};
|
||||
|
||||
const clearExpiredSession = () => {
|
||||
const clearExpiredSession = async () => {
|
||||
if (isAuthRedirectInProgress) {
|
||||
return;
|
||||
}
|
||||
@@ -1034,13 +1034,14 @@
|
||||
clearInterval(tokenTimer);
|
||||
tokenTimer = null;
|
||||
}
|
||||
// Await sign-out so it cannot clear the state of the new OAuth login
|
||||
await userSignOut().catch((error) => {
|
||||
console.error('Error signing out expired session:', error);
|
||||
});
|
||||
user.set(null);
|
||||
localStorage.removeItem('token');
|
||||
// Clear the OAuth token cookie so /auth doesn't auto-login and redirect-loop
|
||||
document.cookie = 'token=; Max-Age=0; path=/';
|
||||
userSignOut().catch((error) => {
|
||||
console.error('Error signing out expired session:', error);
|
||||
});
|
||||
toast.error($i18n.t('Session expired. Please sign in again.'));
|
||||
isAuthRedirectInProgress = false;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user