Add RoleService to AuthModule and UserAuthService

This commit is contained in:
faris Aljohari
2024-12-23 01:37:46 -06:00
parent 67742d018f
commit 53a474d5cf
2 changed files with 9 additions and 0 deletions

View File

@ -18,6 +18,8 @@ import * as argon2 from 'argon2';
import { differenceInSeconds } from '@app/common/helper/differenceInSeconds';
import { LessThan, MoreThan } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { RoleService } from 'src/role/services';
import { RoleType } from '@app/common/constants/role.type.enum';
@Injectable()
export class UserAuthService {
@ -28,6 +30,7 @@ export class UserAuthService {
private readonly helperHashService: HelperHashService,
private readonly authService: AuthService,
private readonly emailService: EmailService,
private readonly roleService: RoleService,
private readonly configService: ConfigService,
) {}
@ -44,9 +47,13 @@ export class UserAuthService {
try {
const { regionUuid, ...rest } = userSignUpDto;
const spaceMemberRole = await this.roleService.findRoleByType(
RoleType.SPACE_MEMBER,
);
const user = await this.userRepository.save({
...rest,
password: hashedPassword,
roleType: { uuid: spaceMemberRole.uuid },
region: regionUuid
? {
uuid: regionUuid,