chore: fix auth problem
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user