add admin setup token i love admin setup token

This commit is contained in:
WaveringAna 2025-01-27 22:32:49 -05:00
parent 660da70666
commit ac13e77dc4
15 changed files with 136 additions and 21 deletions

View file

@ -5,7 +5,7 @@ import * as api from '../api/client';
interface AuthContextType {
user: User | null;
login: (email: string, password: string) => Promise<void>;
register: (email: string, password: string) => Promise<void>;
register: (email: string, password: string, adminToken: string) => Promise<void>;
logout: () => void;
isLoading: boolean;
}
@ -33,8 +33,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
setUser(user);
};
const register = async (email: string, password: string) => {
const response = await api.register(email, password);
const register = async (email: string, password: string, adminToken: string) => {
const response = await api.register(email, password, adminToken);
const { token, user } = response;
localStorage.setItem('token', token);
localStorage.setItem('user', JSON.stringify(user));