initial commit after split
This commit is contained in:
37
webui/src/api/auth.ts
Normal file
37
webui/src/api/auth.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import type { ApiSettings, AuthInfo, LoginResponse } from "../types";
|
||||
import { apiFetch } from "./client";
|
||||
|
||||
export async function login(
|
||||
settings: ApiSettings,
|
||||
payload: { email: string; password: string }
|
||||
): Promise<LoginResponse> {
|
||||
return apiFetch<LoginResponse>({ ...settings, accessToken: "", apiKey: "" }, "/api/v1/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchMe(settings: ApiSettings): Promise<AuthInfo> {
|
||||
return apiFetch<AuthInfo>(settings, "/api/v1/auth/me");
|
||||
}
|
||||
|
||||
export async function switchTenant(settings: ApiSettings, tenantId: string): Promise<AuthInfo> {
|
||||
return apiFetch<AuthInfo>(settings, "/api/v1/auth/switch-tenant", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ tenant_id: tenantId })
|
||||
});
|
||||
}
|
||||
|
||||
export async function logout(settings: ApiSettings): Promise<void> {
|
||||
await apiFetch(settings, "/api/v1/auth/logout", { method: "POST" });
|
||||
}
|
||||
|
||||
export async function updateProfile(
|
||||
settings: ApiSettings,
|
||||
payload: { display_name?: string | null; tenant_display_name?: string | null }
|
||||
): Promise<AuthInfo> {
|
||||
return apiFetch<AuthInfo>(settings, "/api/v1/auth/profile", {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user