Compare commits
2 Commits
73c87f6819
...
5b7df0e372
Author | SHA1 | Date |
---|---|---|
|
5b7df0e372 | |
|
ca886069f1 |
|
@ -49,7 +49,8 @@ export class OtpService {
|
|||
this.hasSequentialDigits(otp) ||
|
||||
this.hasRepeatedDigits(otp) ||
|
||||
this.isPalindrome(otp) ||
|
||||
this.hasPartiallyRepeatedDigits(otp)
|
||||
this.hasPartiallyRepeatedDigits(otp) ||
|
||||
otp?.split('')?.length < this.otpLength
|
||||
);
|
||||
|
||||
return otp;
|
||||
|
|
|
@ -29,7 +29,7 @@ export class OtpVerificationService {
|
|||
return moment().add(minutes, 'minutes').valueOf(); // epoch millis expired time
|
||||
}
|
||||
|
||||
private generateResendAvailableAt(seconds = 90): number {
|
||||
private generateResendAvailableAt(seconds = 60): number {
|
||||
return moment().add(seconds, 'seconds').valueOf(); // epoch millis
|
||||
}
|
||||
|
||||
|
@ -67,14 +67,14 @@ export class OtpVerificationService {
|
|||
};
|
||||
|
||||
const activeOTP = await this.getActiveOtp(
|
||||
payload.target_id ?? payload.reference,
|
||||
payload.target_id ? payload.target_id : payload.reference,
|
||||
);
|
||||
|
||||
if (activeOTP) {
|
||||
const createdAtMoment = moment(Number(activeOTP.created_at));
|
||||
const nowMoment = moment(Number(dateNow));
|
||||
const diffSeconds = nowMoment.diff(createdAtMoment, 'seconds');
|
||||
if (diffSeconds < 90) {
|
||||
if (diffSeconds < 60) {
|
||||
throw new BadRequestException(
|
||||
'An active OTP request was made recently. Please try again later.',
|
||||
);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { BaseDto } from 'src/core/modules/infrastructure/dto/base.dto';
|
||||
import { VipCodeEntity } from '../../domain/entities/vip-code.entity';
|
||||
import { IsNumber, IsObject, IsString } from 'class-validator';
|
||||
import { IsNumber, IsObject, IsString, ValidateIf } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class VipCodeDto extends BaseDto implements VipCodeEntity {
|
||||
|
@ -29,6 +29,7 @@ export class VipCodeDto extends BaseDto implements VipCodeEntity {
|
|||
example: 25000,
|
||||
})
|
||||
@IsNumber()
|
||||
@ValidateIf((v) => v.discount_value)
|
||||
discount_value: number;
|
||||
|
||||
@ApiProperty({
|
||||
|
|
Loading…
Reference in New Issue