Download apps/admin-web/lib/adminAuth.ts from ADI576/proflo: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/ADI576/proflo/resolve/main/apps/admin-web/lib/adminAuth.ts
- Command line
-
hf download hf://spaces/ADI576/proflo/apps/admin-web/lib/adminAuth.ts
-
curl -L -o adminAuth.ts https://huggingface.co/spaces/ADI576/proflo/resolve/main/apps/admin-web/lib/adminAuth.ts
1.08 kB
| const STORAGE_KEY = "checkout_admin_token"; | |
| const ROLE_KEY = "checkout_admin_role"; | |
| export function getAdminToken(): string | null { | |
| if (typeof window === "undefined") return null; | |
| return localStorage.getItem(STORAGE_KEY); | |
| } | |
| export function getAdminRole(): string | null { | |
| if (typeof window === "undefined") return null; | |
| return localStorage.getItem(ROLE_KEY); | |
| } | |
| export function setAdminSession(token: string, role: string): void { | |
| localStorage.setItem(STORAGE_KEY, token); | |
| localStorage.setItem(ROLE_KEY, role); | |
| } | |
| /** @deprecated Prefer setAdminSession — defaults role to staff */ | |
| export function setAdminToken(token: string): void { | |
| setAdminSession(token, "staff"); | |
| } | |
| export function clearAdminToken(): void { | |
| localStorage.removeItem(STORAGE_KEY); | |
| localStorage.removeItem(ROLE_KEY); | |
| } | |
| export function adminFetchHeaders(json = false): HeadersInit { | |
| const headers: Record<string, string> = {}; | |
| if (json) headers["Content-Type"] = "application/json"; | |
| const t = getAdminToken(); | |
| if (t) headers.Authorization = `Bearer ${t}`; | |
| return headers; | |
| } | |