update: domain service
This commit is contained in:
@@ -60,15 +60,15 @@ export class AuthService {
|
||||
try {
|
||||
await entityManager.begin();
|
||||
//
|
||||
const isValid = await this.otpService.verifyOtp(phone, code, "REGISTER");
|
||||
|
||||
if (!isValid) throw new BadRequestException(AuthMessage.INVALID_OTP);
|
||||
|
||||
await this.otpService.delOtpFormCache(phone, "REGISTER");
|
||||
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);
|
||||
|
||||
await entityManager.commit();
|
||||
@@ -113,8 +113,9 @@ export class AuthService {
|
||||
//****************** */
|
||||
//****************** */
|
||||
|
||||
async requestLoginOtp(requestOtpDto: RequestOtpDto, businessId: string, isAdmin: boolean = false) {
|
||||
async requestLoginOtp(requestOtpDto: RequestOtpDto, businessId: string) {
|
||||
const { phone } = requestOtpDto;
|
||||
|
||||
const user = await this.usersService.findOneWithPhone(phone, businessId);
|
||||
if (!user) throw new BadRequestException(AuthMessage.PHONE_NOT_FOUND);
|
||||
|
||||
@@ -122,7 +123,7 @@ export class AuthService {
|
||||
|
||||
const isUserAdmin = this.checkUserIsAdmin(user.role);
|
||||
|
||||
if (isAdmin && !isUserAdmin) throw new BadRequestException(AuthMessage.NOT_ADMIN);
|
||||
if (isUserAdmin) throw new BadRequestException(AuthMessage.NOT_ADMIN);
|
||||
|
||||
const existCode = await this.otpService.checkExistOtp(phone, "LOGIN");
|
||||
if (existCode) {
|
||||
|
||||
Reference in New Issue
Block a user