generated from muhtadeetaron/nextjs-template
added exam routes
This commit is contained in:
10
lib/auth.ts
10
lib/auth.ts
@ -88,3 +88,13 @@ export const getTokenFromCookie = () => {
|
||||
export const clearAuthToken = () => {
|
||||
setCookie("authToken", null);
|
||||
};
|
||||
|
||||
export const getToken = async () => {
|
||||
if (typeof window === "undefined") {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Extract authToken from cookies
|
||||
const match = document.cookie.match(/(?:^|;\s*)authToken=([^;]*)/);
|
||||
return match ? decodeURIComponent(match[1]) : null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user