File size: 554 Bytes
f1dd159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { createContext } from "react";

import type { AdminDTO } from "@/shared/api/client";

export type AuthStatus = "restoring" | "authenticated" | "anonymous" | "unavailable";

export type AuthContextValue = {
  admin: AdminDTO | null;
  status: AuthStatus;
  retryRestore: () => Promise<void>;
  login: (username: string, password: string) => Promise<void>;
  logout: () => Promise<void>;
  changePassword: (currentPassword: string, newPassword: string) => Promise<void>;
};

export const AuthContext = createContext<AuthContextValue | null>(null);