From 65d88ef08ed5819c3d7a1737641a7fe74d64e520 Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Thu, 6 Jun 2024 21:24:25 +0800 Subject: [PATCH] misc: improved ux by requiring captcha entry before submission --- backend/src/services/auth/auth-login-service.ts | 7 ++++++- .../src/views/Login/components/InitialStep/InitialStep.tsx | 2 ++ .../views/Login/components/PasswordStep/PasswordStep.tsx | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/src/services/auth/auth-login-service.ts b/backend/src/services/auth/auth-login-service.ts index 065e304d4..77b39c671 100644 --- a/backend/src/services/auth/auth-login-service.ts +++ b/backend/src/services/auth/auth-login-service.ts @@ -236,7 +236,7 @@ export const authLoginServiceFactory = ({ if (!isValidClientProof) { await userDAL.update( - { id: userEnc.id }, + { id: userEnc.userId }, { $incr: { consecutiveFailedPasswordAttempts: 1 @@ -251,6 +251,11 @@ export const authLoginServiceFactory = ({ serverPrivateKey: null, clientPublicKey: null }); + + await userDAL.updateById(userEnc.userId, { + consecutiveFailedPasswordAttempts: 0 + }); + // send multi factor auth token if they it enabled if (userEnc.isMfaEnabled && userEnc.email) { enforceUserLockStatus(Boolean(user.isLocked), user.temporaryLockDateEnd); diff --git a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx index 0ae253d03..48f7af758 100644 --- a/frontend/src/views/Login/components/InitialStep/InitialStep.tsx +++ b/frontend/src/views/Login/components/InitialStep/InitialStep.tsx @@ -141,6 +141,7 @@ export const InitialStep = ({ setStep, email, setEmail, password, setPassword }: captchaRef.current.resetCaptcha(); } + setCaptchaToken(""); setIsLoading(false); }; @@ -274,6 +275,7 @@ export const InitialStep = ({ setStep, email, setEmail, password, setPassword }: )}