edit login & otp
This commit is contained in:
@@ -128,7 +128,7 @@ export class AuthService {
|
|||||||
const mobile = this.normalizeMobile(dto.mobile);
|
const mobile = this.normalizeMobile(dto.mobile);
|
||||||
const code = String(dto.code ?? '').trim();
|
const code = String(dto.code ?? '').trim();
|
||||||
|
|
||||||
if (!/^\d{4,8}$/.test(code)) {
|
if (!/^\d{4}$/.test(code)) {
|
||||||
throw new BadRequestException('Invalid OTP code');
|
throw new BadRequestException('Invalid OTP code');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generateOtpCode(): string {
|
private generateOtpCode(): string {
|
||||||
return String(randomInt(100000, 1000000));
|
return String(randomInt(1000, 10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
private hashOtp(mobile: string, code: string): string {
|
private hashOtp(mobile: string, code: string): string {
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ export class VerifyOtpDto {
|
|||||||
@IsIranMobile()
|
@IsIranMobile()
|
||||||
mobile!: string;
|
mobile!: string;
|
||||||
|
|
||||||
@ApiProperty({ example: '123456' })
|
@ApiProperty({ example: '1234' })
|
||||||
@IsString()
|
@IsString()
|
||||||
@Matches(/^\d{4,8}$/, {
|
@Matches(/^\d{4}$/, {
|
||||||
message: 'code must be 4 to 8 digits',
|
message: 'code must be 4 digits',
|
||||||
})
|
})
|
||||||
code!: string;
|
code!: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user