Align the project baseline with the latest admin interface styling and layout structure while documenting setup and usage updates in README.
25 lines
743 B
TypeScript
25 lines
743 B
TypeScript
const AUTH_HINT_KEY = "compton-auth-hint";
|
|
const PROTECTED_PATH_PREFIXES = ["/admin", "/profile"] as const;
|
|
|
|
export function markAuthSessionHint(): void {
|
|
sessionStorage.setItem(AUTH_HINT_KEY, "1");
|
|
}
|
|
|
|
export function clearAuthSessionHint(): void {
|
|
sessionStorage.removeItem(AUTH_HINT_KEY);
|
|
}
|
|
|
|
export function hasAuthSessionHint(): boolean {
|
|
return sessionStorage.getItem(AUTH_HINT_KEY) === "1";
|
|
}
|
|
|
|
export function isProtectedAppPath(pathname: string): boolean {
|
|
return PROTECTED_PATH_PREFIXES.some(
|
|
(prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)
|
|
);
|
|
}
|
|
|
|
export function shouldAttemptAuthRefresh(pathname = window.location.pathname): boolean {
|
|
return hasAuthSessionHint() || isProtectedAppPath(pathname);
|
|
}
|