Can reset password
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { atom } from "jotai";
|
||||
import { APIClient } from "./ApiClient";
|
||||
import { url } from "inspector";
|
||||
|
||||
export interface CheckResetTokenResponse {
|
||||
name: string;
|
||||
@ -92,4 +93,18 @@ export class AuthApi {
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset password
|
||||
*/
|
||||
static async ResetPassword(
|
||||
token: string,
|
||||
newPassword: string
|
||||
): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: "/auth/reset_password",
|
||||
method: "POST",
|
||||
jsonData: { token: token, password: newPassword },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,18 @@ export class ServerApi {
|
||||
if (config === null) throw new Error("Missing configuration!");
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check password against policy
|
||||
*
|
||||
* @returns The detected error (if any) or null if the password
|
||||
* is valid
|
||||
*/
|
||||
static CheckPassword(pwd: string): string | null {
|
||||
const constraint = this.Config.constraints.password_len;
|
||||
if (pwd.length < constraint.min || pwd.length > constraint.max)
|
||||
return `Le mot de passe doit comporter entre ${constraint.min} et ${constraint.max} caractères`;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user