updated forget password functionality with backend
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const changePasswordApi = async (
|
||||
resetToken: string,
|
||||
newPassword: string,
|
||||
confirmPassword: string
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Auth/reset-password/${resetToken}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ newPassword, confirmPassword }),
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to create password");
|
||||
if (error instanceof Error) {
|
||||
return { error: error.message };
|
||||
} else {
|
||||
return { error: "An unknown error occurred" };
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const checkEmailApi = async (Email: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Auth/forgetPassword`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ Email }),
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to create password");
|
||||
if (error instanceof Error) {
|
||||
return { error: error.message };
|
||||
} else {
|
||||
return { error: "An unknown error occurred" };
|
||||
}
|
||||
}
|
||||
};
|
||||
28
app/src/services/factoryBuilder/signInSignUp/verifyOtpApi.ts
Normal file
28
app/src/services/factoryBuilder/signInSignUp/verifyOtpApi.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const verifyOtpApi = async (Email: string, Otp: number) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/Auth/validate-otp`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
Email,
|
||||
otp: Number(Otp),
|
||||
}),
|
||||
}
|
||||
);
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to create password");
|
||||
if (error instanceof Error) {
|
||||
return { error: error.message };
|
||||
} else {
|
||||
return { error: "An unknown error occurred" };
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user