arbret/frontend/app/api/auth.ts

42 lines
910 B
TypeScript
Raw Normal View History

import { client } from "./client";
import { components } from "../generated/api";
type User = components["schemas"]["UserResponse"];
/**
* Authentication API endpoints
*/
export const authApi = {
/**
* Get current authenticated user
*/
getMe(): Promise<User> {
return client.get<User>("/api/auth/me");
},
/**
* Login with email and password
*/
login(email: string, password: string): Promise<User> {
return client.post<User>("/api/auth/login", { email, password });
},
/**
* Register a new user with invite code
*/
register(email: string, password: string, inviteIdentifier: string): Promise<User> {
return client.post<User>("/api/auth/register", {
email,
password,
invite_identifier: inviteIdentifier,
});
},
/**
* Logout current user
*/
logout(): Promise<void> {
return client.post<void>("/api/auth/logout");
},
};