From 75dceaad85465172e0b6bb9c42c41368d447160f Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:19:19 +0530 Subject: [PATCH 1/3] Fix password reset --- src/Redux/api.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Redux/api.tsx b/src/Redux/api.tsx index 9cf9a0b6643..8a4ca5cf1df 100644 --- a/src/Redux/api.tsx +++ b/src/Redux/api.tsx @@ -55,6 +55,7 @@ const routes = { checkResetToken: { path: "/api/v1/password_reset/check/", method: "POST", + noAuth: true, TRes: Type>(), TBody: Type<{ token: string }>(), }, @@ -62,6 +63,7 @@ const routes = { resetPassword: { path: "/api/v1/password_reset/confirm/", method: "POST", + noAuth: true, TRes: Type>(), TBody: Type<{ password: string; confirm: string }>(), }, @@ -69,6 +71,7 @@ const routes = { forgotPassword: { path: "/api/v1/password_reset/", method: "POST", + noAuth: true, TRes: Type>(), TBody: Type<{ username: string }>(), }, From 1230555006fb73ed52853f1aed1b77d7339f6c55 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:55:06 +0530 Subject: [PATCH 2/3] fix response status check --- src/Components/Auth/Login.tsx | 2 +- src/Components/Auth/ResetPassword.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Auth/Login.tsx b/src/Components/Auth/Login.tsx index dd6a42d3983..140a0013fd9 100644 --- a/src/Components/Auth/Login.tsx +++ b/src/Components/Auth/Login.tsx @@ -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"), }); diff --git a/src/Components/Auth/ResetPassword.tsx b/src/Components/Auth/ResetPassword.tsx index 2f02737f6de..74e37560515 100644 --- a/src/Components/Auth/ResetPassword.tsx +++ b/src/Components/Auth/ResetPassword.tsx @@ -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"), @@ -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"); } }; From 3760ae2bc416ce9ebc37f53c6db9d630cce88030 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:05:50 +0530 Subject: [PATCH 3/3] Update ResetPassword.tsx --- src/Components/Auth/ResetPassword.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Auth/ResetPassword.tsx b/src/Components/Auth/ResetPassword.tsx index 74e37560515..47d120e1a97 100644 --- a/src/Components/Auth/ResetPassword.tsx +++ b/src/Components/Auth/ResetPassword.tsx @@ -89,7 +89,7 @@ export const ResetPassword = (props: any) => { const { res } = await request(routes.checkResetToken, { body: { token: props.token }, }); - if (!res || res.ok) { + if (!res || !res.ok) { navigate("/invalid-reset"); } };