🔒 security: handle unauthorization user
This commit is contained in:
@ -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({
|
||||||
|
|||||||
Reference in New Issue
Block a user