ci/woodpecker/push/woodpecker Pipeline was successful
Co-authored-by: HiFox Agent <agents-noreply@hifox.com>
28 lines
579 B
TypeScript
28 lines
579 B
TypeScript
import { createContext, useContext } from 'react';
|
|
|
|
export interface AuthState {
|
|
mode?: 'sso' | 'password';
|
|
loginWithPassword?: (password: string) => Promise<void>;
|
|
isLoading: boolean;
|
|
isAuthenticated: boolean;
|
|
user: {
|
|
userId: string;
|
|
userName: string;
|
|
permissionLevel: string;
|
|
depName: string;
|
|
roles?: string[];
|
|
} | null;
|
|
error: string | null;
|
|
}
|
|
|
|
export const AuthContext = createContext<AuthState>({
|
|
isLoading: true,
|
|
isAuthenticated: false,
|
|
user: null,
|
|
error: null,
|
|
});
|
|
|
|
export function useAuth() {
|
|
return useContext(AuthContext);
|
|
}
|