fix: bug in the auth service
This commit is contained in:
@@ -56,8 +56,8 @@ export class UsersService {
|
||||
async createUser(registerDto: CompleteRegistrationDto | CreateCompanyDto, hashedPassword: string, business: Business, em: EntityManager) {
|
||||
const [role, existPhone, existUser] = await Promise.all([
|
||||
em.findOne(Role, { name: RoleEnum.USER }),
|
||||
em.findOne(User, { phone: registerDto.phone }),
|
||||
em.findOne(User, { nationalCode: registerDto.nationalCode }),
|
||||
em.findOne(User, { phone: registerDto.phone, business: { id: business.id } }),
|
||||
em.findOne(User, { nationalCode: registerDto.nationalCode, business: { id: business.id } }),
|
||||
]);
|
||||
|
||||
if (!role) throw new BadRequestException(UserMessage.ROLE_NOT_FOUND);
|
||||
@@ -65,7 +65,7 @@ export class UsersService {
|
||||
if (existUser) throw new BadRequestException(UserMessage.NATIONAL_CODE_EXIST);
|
||||
|
||||
if ("email" in registerDto) {
|
||||
const existEmail = await em.findOne(User, { email: registerDto.email });
|
||||
const existEmail = await em.findOne(User, { email: registerDto.email, business: { id: business.id } });
|
||||
if (existEmail) throw new BadRequestException(UserMessage.EMAIL_EXIST);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user