From 909a2d18bcb92ae165dd5408674e375a3c85604a Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 19 Dec 2024 18:26:12 +0200 Subject: [PATCH] refactor: change sus initialization --- modules/authentication/src/utils/index.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/authentication/src/utils/index.ts b/modules/authentication/src/utils/index.ts index 65994c98d..98b281753 100644 --- a/modules/authentication/src/utils/index.ts +++ b/modules/authentication/src/utils/index.ts @@ -122,14 +122,13 @@ export namespace AuthUtils { ); } - export function checkResendThreshold( - token: Token, - notBefore: number = ConfigController.getInstance().config.local.verification - .resend_threshold, - ) { + export function checkResendThreshold(token: Token, notBefore?: number) { + const threshold = + notBefore || + ConfigController.getInstance().config.local.verification.resend_threshold; const diffInMilliSec = Math.abs(new Date(token.createdAt).getTime() - Date.now()); - if (diffInMilliSec < notBefore) { - const remainTimeInSec = Math.ceil((notBefore - diffInMilliSec) / 1000); + if (diffInMilliSec < threshold) { + const remainTimeInSec = Math.ceil((threshold - diffInMilliSec) / 1000); throw new GrpcError( status.RESOURCE_EXHAUSTED, 'Verification not sent. You have to wait ' +