mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 14:43:06 +08:00
662460252f
* feat(EE): MFA implementation for enterprise edition - Add TOTP-based two-factor authentication - Add backup codes support - Add MFA enforcement at workspace level - Add MFA setup and challenge UI pages - Support MFA for login and password reset flows - Add MFA validation for secure pages * fix types * remove unused object * sync * remove unused type * sync * refactor: rename MFA enabled field to is_enabled * sync
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import api from "@/lib/api-client";
|
|
import {
|
|
IChangePassword,
|
|
ICollabToken,
|
|
IForgotPassword,
|
|
ILogin,
|
|
ILoginResponse,
|
|
IPasswordReset,
|
|
ISetupWorkspace,
|
|
IVerifyUserToken,
|
|
} from "@/features/auth/types/auth.types";
|
|
import { IWorkspace } from "@/features/workspace/types/workspace.types.ts";
|
|
|
|
export async function login(data: ILogin): Promise<ILoginResponse> {
|
|
const response = await api.post<ILoginResponse>("/auth/login", data);
|
|
return response.data;
|
|
}
|
|
|
|
export async function logout(): Promise<void> {
|
|
await api.post<void>("/auth/logout");
|
|
}
|
|
|
|
export async function changePassword(
|
|
data: IChangePassword,
|
|
): Promise<IChangePassword> {
|
|
const req = await api.post<IChangePassword>("/auth/change-password", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function setupWorkspace(
|
|
data: ISetupWorkspace,
|
|
): Promise<IWorkspace> {
|
|
const req = await api.post<IWorkspace>("/auth/setup", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function forgotPassword(data: IForgotPassword): Promise<void> {
|
|
await api.post<void>("/auth/forgot-password", data);
|
|
}
|
|
|
|
export async function passwordReset(data: IPasswordReset): Promise<{ requiresLogin?: boolean; }> {
|
|
const req = await api.post("/auth/password-reset", data);
|
|
return req.data;
|
|
}
|
|
|
|
export async function verifyUserToken(data: IVerifyUserToken): Promise<any> {
|
|
return api.post<any>("/auth/verify-token", data);
|
|
}
|
|
|
|
export async function getCollabToken(): Promise<ICollabToken> {
|
|
const req = await api.post<ICollabToken>("/auth/collab-token");
|
|
return req.data;
|
|
} |