fix: clear token cookie on 401 auth redirect to stop login flash loop (#26751)
Since v0.10.0 a global fetch interceptor redirects to /auth and clears
localStorage.token whenever an authenticated backend request returns 401.
The OAuth callback cookie ("token", set with httponly=False so the
frontend can read it) is left behind. The auth page's oauthCallbackHandler
then immediately signs the user back in from that cookie and navigates to
"/", where the next 401 triggers the redirect again. The result is an
endless /auth and / ping-pong that renders as uncontrollable screen
flashing, and as a PWA stuck on a flashing splash screen when SvelteKit's
update check turns each navigation into a full page reload. Affected
users could only recover by clearing cookies, which matches the reports.
Clear the token cookie together with localStorage when redirecting, so
/auth stays on the login form and the user can sign in again normally.
Fixes #26731
This commit is contained in:
@@ -849,6 +849,8 @@
|
||||
}
|
||||
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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user