fixed all admin email pages. added admin user info and button on builder page to route to admin page.
CI / test (push) Successful in 5s
CI / test (push) Successful in 5s
This commit is contained in:
@@ -33,6 +33,7 @@ type AuthContextValue = {
|
||||
register: (params: RegisterParams) => Promise<void>;
|
||||
logout: () => void;
|
||||
refreshUser: () => Promise<void>;
|
||||
getAuthHeaders: () => HeadersInit;
|
||||
};
|
||||
|
||||
const AuthContext = createContext<AuthContextValue | undefined>(undefined);
|
||||
@@ -210,6 +211,15 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
}).catch(() => {});
|
||||
}, [persistUser]);
|
||||
|
||||
const getAuthHeaders = useCallback((): HeadersInit => {
|
||||
if (typeof window === "undefined") return {};
|
||||
const token =
|
||||
localStorage.getItem("token") ||
|
||||
localStorage.getItem("jwt") ||
|
||||
localStorage.getItem("accessToken");
|
||||
return token ? { Authorization: `Bearer ${token}` } : {};
|
||||
}, []);
|
||||
|
||||
const value: AuthContextValue = {
|
||||
user,
|
||||
loading,
|
||||
@@ -217,6 +227,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
register,
|
||||
logout,
|
||||
refreshUser,
|
||||
getAuthHeaders,
|
||||
};
|
||||
|
||||
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
||||
|
||||
Reference in New Issue
Block a user