Files
Stirling-PDF/frontend/shared/auth/spring/oauthStorage.ts
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1022 B
TypeScript
Raw Normal View History

2026-01-09 18:21:16 +00:00
/**
* Helper utilities for clearing cached OAuth redirect/session state
*/
const OAUTH_REDIRECT_COOKIE = "stirling_redirect_path";
2026-01-09 18:21:16 +00:00
/**
* Clear any persisted OAuth redirect path/cached state so the app
* does not automatically resume a previous OAuth session after logout.
*/
export function resetOAuthState(): void {
try {
// Remove redirect cookie
if (typeof document !== "undefined") {
2026-01-09 18:21:16 +00:00
document.cookie = `${OAUTH_REDIRECT_COOKIE}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;SameSite=Lax`;
}
} catch (err) {
console.warn("[OAuthStorage] Failed to clear redirect cookie", err);
2026-01-09 18:21:16 +00:00
}
// Remove any related localStorage entries we might have used
try {
if (typeof window !== "undefined" && window.localStorage) {
2026-01-09 18:21:16 +00:00
window.localStorage.removeItem(OAUTH_REDIRECT_COOKIE);
window.localStorage.removeItem("oauth_redirect_path");
2026-01-09 18:21:16 +00:00
}
} catch (err) {
console.warn("[OAuthStorage] Failed to clear OAuth localStorage", err);
2026-01-09 18:21:16 +00:00
}
}
export default {
resetOAuthState,
};