Spaces:
Running
Running
Ashraf Al-Kassem
Claude Sonnet 4.6
fix(admin): correct basePath-prefixed hrefs for logout and product login link
dffa8ae Download frontend/src/lib/admin-auth.ts from ashrafkassem/LeadPilot: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/ashrafkassem/LeadPilot/resolve/main/frontend/src/lib/admin-auth.ts
- Command line
-
hf download hf://spaces/ashrafkassem/LeadPilot/frontend/src/lib/admin-auth.ts
-
curl -L -o admin-auth.ts https://huggingface.co/spaces/ashrafkassem/LeadPilot/resolve/main/frontend/src/lib/admin-auth.ts
1.13 kB
| /** | |
| * Admin Auth Utility for LeadPilot Admin Portal | |
| * Stores the admin JWT separately from the product JWT. | |
| * Do NOT mix with src/lib/auth.ts (product user session). | |
| */ | |
| const ADMIN_TOKEN_KEY = "leadpilot_admin_token"; | |
| export interface AdminUser { | |
| id: string; | |
| email: string; | |
| full_name: string; | |
| is_superuser: boolean; | |
| role?: { name: string; permissions: string[] } | null; | |
| } | |
| export const adminAuth = { | |
| getToken: (): string | null => { | |
| if (typeof window === "undefined") return null; | |
| return localStorage.getItem(ADMIN_TOKEN_KEY); | |
| }, | |
| setToken: (token: string): void => { | |
| if (typeof window === "undefined") return; | |
| localStorage.setItem(ADMIN_TOKEN_KEY, token); | |
| }, | |
| clearToken: (): void => { | |
| if (typeof window === "undefined") return; | |
| localStorage.removeItem(ADMIN_TOKEN_KEY); | |
| }, | |
| isAuthed: (): boolean => { | |
| return !!adminAuth.getToken(); | |
| }, | |
| logout: (): void => { | |
| adminAuth.clearToken(); | |
| if (typeof window !== "undefined") { | |
| window.location.href = "/app/admin/login"; | |
| } | |
| }, | |
| }; | |