Ajoute le flux d'invitation avec activation de compte

This commit is contained in:
2026-07-19 19:40:38 +02:00
parent 08b9bb8095
commit 18bf4e60d1
13 changed files with 747 additions and 97 deletions
+30
View File
@@ -23,6 +23,12 @@ type PasswordResetValidationPayload = {
error?: string;
};
type AccountInviteValidationPayload = {
email?: string;
name?: string | null;
error?: string;
};
type JsonErrorPayload = {
error?: string;
};
@@ -131,6 +137,30 @@ export function createAuthClient(options: CreateAuthClientOptions) {
}
},
async validateAccountInviteToken(token: string): Promise<{ email: string; name: string | null }> {
const response = await request(`/api/auth/invite/validate?token=${encodeURIComponent(token)}`, {
headers: {}
});
const payload = (await response.json().catch(() => null)) as AccountInviteValidationPayload | null;
if (!response.ok || !payload?.email) {
throw new Error(payload?.error ?? "Invalid invite link");
}
return {
email: payload.email,
name: payload.name ?? null
};
},
async acceptAccountInvite(input: { token: string; name: string; password: string }): Promise<void> {
const response = await request("/api/auth/invite/accept", {
method: "POST",
body: JSON.stringify(input)
});
if (!response.ok) {
throw await readJsonError(response, "Invalid invite link");
}
},
async logout(): Promise<void> {
const response = await request("/api/auth/logout", {
method: "POST"