From 0d852cf0d1f11cdc41f0eb158c0ec9521a610960 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 11 Aug 2024 10:56:47 +0300 Subject: [PATCH] added cooldown to data --- src/auth/services/user-auth.service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/auth/services/user-auth.service.ts b/src/auth/services/user-auth.service.ts index 085807a..ef47a5a 100644 --- a/src/auth/services/user-auth.service.ts +++ b/src/auth/services/user-auth.service.ts @@ -169,9 +169,12 @@ export class UserAuthService { const timeSinceLastOtp = differenceInSeconds(now, lastOtp.createdAt); if (timeSinceLastOtp < cooldown) { - throw new BadRequestException( - `Please wait ${cooldown - timeSinceLastOtp} more seconds before requesting a new OTP.`, - ); + throw new BadRequestException({ + message: `Please wait ${cooldown - timeSinceLastOtp} more seconds before requesting a new OTP.`, + data: { + cooldown: cooldown - timeSinceLastOtp, + }, + }); } } const otpCode = Math.floor(100000 + Math.random() * 900000).toString();