Skip to content

Commit

Permalink
Fix password reset (#6404)
Browse files Browse the repository at this point in the history
* Fix password reset

* fix response status check

* Update ResetPassword.tsx
  • Loading branch information
Ashesh3 authored Oct 6, 2023
1 parent 64c0b24 commit 91abee0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Components/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const Login = (props: { forgot?: boolean }) => {
body: { ...valid },
});
setLoading(false);
if (res && res.statusText === "OK") {
if (res?.ok) {
Notification.Success({
msg: t("password_sent"),
});
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Auth/ResetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const ResetPassword = (props: any) => {
const { res, error } = await request(routes.resetPassword, {
body: { ...valid },
});
if (res && res.statusText === "OK") {
if (res?.ok) {
localStorage.removeItem(LocalStorageKeys.accessToken);
Notification.Success({
msg: t("password_reset_success"),
Expand All @@ -89,7 +89,7 @@ export const ResetPassword = (props: any) => {
const { res } = await request(routes.checkResetToken, {
body: { token: props.token },
});
if (!res || res.statusText !== "OK") {
if (!res || !res.ok) {
navigate("/invalid-reset");
}
};
Expand Down
3 changes: 3 additions & 0 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,23 @@ const routes = {
checkResetToken: {
path: "/api/v1/password_reset/check/",
method: "POST",
noAuth: true,
TRes: Type<Record<string, never>>(),
TBody: Type<{ token: string }>(),
},

resetPassword: {
path: "/api/v1/password_reset/confirm/",
method: "POST",
noAuth: true,
TRes: Type<Record<string, never>>(),
TBody: Type<{ password: string; confirm: string }>(),
},

forgotPassword: {
path: "/api/v1/password_reset/",
method: "POST",
noAuth: true,
TRes: Type<Record<string, never>>(),
TBody: Type<{ username: string }>(),
},
Expand Down

0 comments on commit 91abee0

Please sign in to comment.