chore: fix auth problem

This commit is contained in:
mahyargdz
2025-06-01 11:11:33 +03:30
parent 3f3d4d976a
commit 8d335429e2
+5 -2
View File
@@ -61,10 +61,11 @@ export class AuthService {
await queryRunner.startTransaction(); await queryRunner.startTransaction();
// //
const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER"); const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER");
if (!isValid) throw new BadRequestException(AuthMessage.INVALID_OTP); 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 hashedPassword = await this.passwordService.hashPassword(completeRegistrationDto.password);
const user = await this.usersService.createUser(completeRegistrationDto, hashedPassword, queryRunner); 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(); await queryRunner.commitTransaction();
return { return {