sign in and register fixes for looped and forwarded pages

This commit is contained in:
makearmy 2025-10-02 14:21:12 -04:00
parent 5257a0d2fe
commit ffccff85d4
6 changed files with 68 additions and 20 deletions

15
lib/jwt.ts Normal file
View file

@ -0,0 +1,15 @@
// lib/jwt.ts
export function jwtExp(token?: string | null): number | null {
if (!token) return null;
try {
const payload = JSON.parse(Buffer.from(token.split(".")[1], "base64").toString("utf8"));
return typeof payload?.exp === "number" ? payload.exp : null;
} catch {
return null;
}
}
export function isJwtValid(token?: string | null): boolean {
const exp = jwtExp(token);
return !!exp && exp * 1000 > Date.now();
}