mirror of
https://github.com/storytold/artcraft.git
synced 2026-10-20 17:02:53 -04:00
password reset fail message
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ApiManager, ApiResponse } from "./ApiManager.js";
|
||||
import { FetchProxy as fetch } from "@storyteller/tauri-utils";
|
||||
|
||||
export class PasswordResetApi extends ApiManager {
|
||||
public async RequestPasswordReset({
|
||||
@@ -58,30 +59,29 @@ export class PasswordResetApi extends ApiManager {
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await this.post<
|
||||
{
|
||||
reset_token: string;
|
||||
new_password: string;
|
||||
new_password_validation: string;
|
||||
const response = await fetch(endpoint, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
{
|
||||
success: boolean;
|
||||
error_type?: string;
|
||||
error_fields?: Record<string, string>;
|
||||
error_message?: string;
|
||||
}
|
||||
>({
|
||||
endpoint: endpoint,
|
||||
body: body,
|
||||
credentials: "include",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
return {
|
||||
success: false,
|
||||
errorMessage:
|
||||
data.message ||
|
||||
"Failed to reset password. Please try again.",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: response.success,
|
||||
errorMessage:
|
||||
response.error_message ||
|
||||
(response.error_fields
|
||||
? Object.values(response.error_fields).join(", ")
|
||||
: undefined),
|
||||
success: data.success,
|
||||
};
|
||||
} catch (err: any) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user