added cooldown to data

This commit is contained in:
unknown
2024-08-11 10:56:47 +03:00
parent a899633d8c
commit 0d852cf0d1

View File

@ -169,9 +169,12 @@ export class UserAuthService {
const timeSinceLastOtp = differenceInSeconds(now, lastOtp.createdAt); const timeSinceLastOtp = differenceInSeconds(now, lastOtp.createdAt);
if (timeSinceLastOtp < cooldown) { if (timeSinceLastOtp < cooldown) {
throw new BadRequestException( throw new BadRequestException({
`Please wait ${cooldown - timeSinceLastOtp} more seconds before requesting a new OTP.`, 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(); const otpCode = Math.floor(100000 + Math.random() * 900000).toString();