Files
buzz-sheet/lib/auth/sudloh-redirect.ts
T
gunshiz 445865bf42
CI / Verify (push) Successful in 1m31s
CI / Build immutable images and deploy (push) Successful in 2m4s
fix(auth) : bind Sudloh sessions and stop OAuth redirect loops
2026-10-06 14:28:59 +07:00

25 lines
981 B
TypeScript

const attemptKey = "sudloh-oidc-last-start";
const attemptWindowMs = 5 * 60 * 1000;
export function sudlohStartErrorMessage(status?: number): string {
return status === 429
? "ลองเข้าสู่ระบบบ่อยเกินไป กรุณารอสักครู่แล้วลองอีกครั้ง"
: "ไม่สามารถเริ่มเข้าสู่ระบบได้ กรุณาลองอีกครั้ง";
}
export function markSudlohSignInAttempt() {
try { sessionStorage.setItem(attemptKey, String(Date.now())); }
catch { /* A manual retry remains available when storage is blocked. */ }
}
export function claimAutomaticSudlohSignIn(): boolean {
try {
const lastAttempt = Number(sessionStorage.getItem(attemptKey));
if (lastAttempt > 0 && Date.now() - lastAttempt < attemptWindowMs) return false;
markSudlohSignInAttempt();
return true;
} catch {
return false;
}
}