2026-01-09 18:21:16 +00:00
|
|
|
/**
|
|
|
|
|
* Helper utilities for clearing cached OAuth redirect/session state
|
|
|
|
|
*/
|
|
|
|
|
|
2026-04-10 17:41:19 +01:00
|
|
|
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
|
2026-04-10 17:41:19 +01:00
|
|
|
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) {
|
2026-04-10 17:41:19 +01:00
|
|
|
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 {
|
2026-04-10 17:41:19 +01:00
|
|
|
if (typeof window !== "undefined" && window.localStorage) {
|
2026-01-09 18:21:16 +00:00
|
|
|
window.localStorage.removeItem(OAUTH_REDIRECT_COOKIE);
|
2026-04-10 17:41:19 +01:00
|
|
|
window.localStorage.removeItem("oauth_redirect_path");
|
2026-01-09 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
} catch (err) {
|
2026-04-10 17:41:19 +01:00
|
|
|
console.warn("[OAuthStorage] Failed to clear OAuth localStorage", err);
|
2026-01-09 18:21:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
resetOAuthState,
|
|
|
|
|
};
|