fix: auth
This commit is contained in:
@@ -61,12 +61,16 @@ export class AuthService {
|
||||
await entityManager.begin();
|
||||
//
|
||||
|
||||
const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER");
|
||||
if (!isValid) throw new BadRequestException(AuthMessage.INVALID_OTP);
|
||||
|
||||
const existUser = await this.usersService.findOneWithPhone(phone, business.id);
|
||||
if (existUser) throw new BadRequestException(AuthMessage.PHONE_EXISTS);
|
||||
|
||||
const hashedPassword = await this.passwordService.hashPassword(completeRegistrationDto.password);
|
||||
|
||||
const user = await this.usersService.createUser(completeRegistrationDto, hashedPassword, business, entityManager);
|
||||
|
||||
const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER");
|
||||
if (!isValid) throw new BadRequestException(AuthMessage.INVALID_OTP);
|
||||
await this.otpService.delOtpFormCache(phone, "REGISTER");
|
||||
|
||||
const tokens = await this.tokensService.generateTokens(user, entityManager);
|
||||
|
||||
Reference in New Issue
Block a user