This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { api, apiGet, apiPost } from "./api";
|
||||
import type { Admin, AuthResponse, AuthStatus, ChangePasswordInput, LoginCredentials } from "../types/auth";
|
||||
|
||||
export function getAuthStatus(): Promise<AuthStatus> {
|
||||
return apiGet<AuthStatus>("/api/auth/status");
|
||||
}
|
||||
|
||||
export function getSession(): Promise<AuthResponse> {
|
||||
return apiGet<AuthResponse>("/api/auth/session");
|
||||
}
|
||||
|
||||
export function login(credentials: LoginCredentials): Promise<AuthResponse> {
|
||||
return apiPost<AuthResponse>("/api/auth/login", credentials);
|
||||
}
|
||||
|
||||
export function logout(): Promise<void> {
|
||||
return apiPost<void>("/api/auth/logout");
|
||||
}
|
||||
|
||||
export function changePassword(input: ChangePasswordInput): Promise<AuthResponse> {
|
||||
return apiPost<AuthResponse>("/api/auth/change-password", input);
|
||||
}
|
||||
|
||||
export type { Admin, AuthResponse, AuthStatus, ChangePasswordInput, LoginCredentials };
|
||||
|
||||
// Keep a typed escape hatch for future authenticated services without exposing fetch details.
|
||||
export { api };
|
||||
Reference in New Issue
Block a user