From 8d335429e289067af518d04f5853df3ef9fe144e Mon Sep 17 00:00:00 2001 From: mahyargdz Date: Sun, 1 Jun 2025 11:11:33 +0330 Subject: [PATCH] chore: fix auth problem --- src/modules/auth/providers/auth.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/auth/providers/auth.service.ts b/src/modules/auth/providers/auth.service.ts index 4e25c17..a702135 100755 --- a/src/modules/auth/providers/auth.service.ts +++ b/src/modules/auth/providers/auth.service.ts @@ -61,10 +61,11 @@ export class AuthService { await queryRunner.startTransaction(); // const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER"); - if (!isValid) throw new BadRequestException(AuthMessage.INVALID_OTP); - await this.otpService.delOtpFormCache(phone, "REGISTER"); + const existUser = await this.usersService.findOneWithPhone(phone); + if (existUser) throw new BadRequestException(AuthMessage.PHONE_EXISTS); + const hashedPassword = await this.passwordService.hashPassword(completeRegistrationDto.password); const user = await this.usersService.createUser(completeRegistrationDto, hashedPassword, queryRunner); @@ -83,6 +84,8 @@ export class AuthService { }); } + await this.otpService.delOtpFormCache(phone, "REGISTER"); + await queryRunner.commitTransaction(); return {