Files
TallyNote/web-next/src/services/auth.ts
T
Qiufeng 12495fb6a4
TallyNote release / linux-x64 (push) Successful in 6m24s
release: 1.1.0
2026-08-31 20:11:34 +08:00

28 lines
961 B
TypeScript

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 };