Files
windmill/frontend/src/lib/logout.ts
T
Alexander PetricandClaude Opus 5.5 987c321ebc fix: uniform decrypt error and clear stored credentials on logout (#11632)
* fix: uniform decrypt error and clear stored credentials on logout

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kv72vdCDggCZEjJSmNCwnX

* fix: also clear mcp-oauth-callback on logout, cover the new keys in the logout test

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kv72vdCDggCZEjJSmNCwnX

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-08 22:32:55 +02:00

34 lines
1.2 KiB
TypeScript

import { noteSessionEmail } from './onboardingProfile'
import { accountSetup } from './components/sidebar/accountSetup.svelte'
import { UserService } from '$lib/gen'
import { clearStores } from './storeUtils'
// Note: logout and logoutWithRedirect have been moved to logoutKit.ts
// as they depend on SvelteKit navigation
// Every browser-storage entry that can hold a credential must go on logout. The impersonation
// backup is the impersonator's own auth token; `oauth-callback` and `mcp-oauth-callback` carry a
// connected account's token response when the OAuth popup had no opener to post it to;
// `test_dev_token` is the session token of the /test_dev pages.
function clearCredentialsFromStorage(): void {
try {
sessionStorage.removeItem('pre_impersonation_token')
sessionStorage.removeItem('pre_impersonation_email')
localStorage.removeItem('oauth-callback')
localStorage.removeItem('mcp-oauth-callback')
localStorage.removeItem('test_dev_token')
} catch (e) {
console.error('error interacting with browser storage', e)
}
}
export async function clearUser() {
try {
noteSessionEmail(undefined)
accountSetup.reset()
clearStores()
clearCredentialsFromStorage()
await UserService.logout()
} catch (error) {}
}