20 lines
473 B
TypeScript
20 lines
473 B
TypeScript
import { createContext } from 'react';
|
|
|
|
export interface User {
|
|
user_id: number;
|
|
role: string;
|
|
name?: string;
|
|
email?: string;
|
|
}
|
|
|
|
export interface AuthContextType {
|
|
user: User | null;
|
|
login: (token?: string) => Promise<void>;
|
|
logout: () => void;
|
|
changePassword: (oldPassword: string, newPassword: string) => Promise<void>;
|
|
isAuthenticated: boolean;
|
|
isLoading: boolean;
|
|
}
|
|
|
|
export const AuthContext = createContext<AuthContextType | undefined>(undefined);
|