fix(auth) : bind Sudloh sessions and stop OAuth redirect loops
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user