🔒 security: handle unauthorization user

This commit is contained in:
2026-01-21 10:29:48 +07:00
parent 19b15b89d2
commit 0a9f011f08

View File

@ -29,8 +29,13 @@ export interface UserSession {
exp: number; exp: number;
} }
export const validateAndDecodeJWT = async (): Promise<UserSession> => { export const validateAndDecodeJWT = async (): Promise<UserSession | null> => {
const cookieHeader = (await cookies()).get("auth_token")?.value; const cookieHeader = (await cookies()).get("auth_token")?.value;
if (!cookieHeader) {
return null;
}
const res = (await backendFetch("auth/token/validate", { const res = (await backendFetch("auth/token/validate", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({