feat: add waiting number and handle resent otp

This commit is contained in:
Abdalhamid Alhamad
2025-03-16 11:34:08 +03:00
parent 9b5f863577
commit ec38b82a7b
7 changed files with 68 additions and 5 deletions

View File

@ -15,8 +15,11 @@ export class OtpService {
private readonly otpRepository: OtpRepository,
private readonly notificationService: NotificationsService,
) {}
private useMock = this.configService.get<boolean>('USE_MOCK', false);
private useMock = [true, 'true'].includes(this.configService.get<boolean>('USE_MOCK', false));
async generateAndSendOtp(sendOtpRequest: ISendOtp): Promise<string> {
this.logger.log(`invalidate OTP for ${sendOtpRequest.recipient} and ${sendOtpRequest.otpType}`);
await this.otpRepository.invalidateOtp(sendOtpRequest);
this.logger.log(`Generating OTP for ${sendOtpRequest.recipient}`);
const otp = this.useMock ? DEFAULT_OTP_DIGIT.repeat(DEFAULT_OTP_LENGTH) : generateRandomOtp(DEFAULT_OTP_LENGTH);