From fe4cc950d31d0eb5fab825b2cd6c3132772ccfae Mon Sep 17 00:00:00 2001 From: Sheen Capadngan Date: Tue, 28 May 2024 01:41:16 +0800 Subject: [PATCH] misc: updated temporary lock error message --- backend/src/services/auth/auth-fns.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/services/auth/auth-fns.ts b/backend/src/services/auth/auth-fns.ts index 30297e605..2a322fdea 100644 --- a/backend/src/services/auth/auth-fns.ts +++ b/backend/src/services/auth/auth-fns.ts @@ -56,12 +56,15 @@ export const enforceUserLockStatus = (isLocked: boolean, temporaryLockDateEnd?: if (temporaryLockDateEnd) { const timeDiff = new Date().getTime() - temporaryLockDateEnd.getTime(); - if (timeDiff < 0) + if (timeDiff < 0) { + const secondsDiff = (-1 * timeDiff) / 1000; + const timeDisplay = + secondsDiff > 60 ? `${Math.ceil(secondsDiff / 60)} minutes` : `${Math.ceil(secondsDiff)} seconds`; + throw new UnauthorizedError({ name: "User Locked", - message: `User is locked due to multiple failed login attempts. Try again after ${Math.round( - (-1 * timeDiff) / 1000 - )} seconds.` + message: `User is temporary locked due to multiple failed login attempts. Try again after ${timeDisplay}. You can also reset your password now to proceed.` }); + } } };