mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 12:04:53 +00:00
Add RoleService to AuthModule and UserAuthService
This commit is contained in:
@ -8,6 +8,7 @@ import { UserRepository } from '@app/common/modules/user/repositories';
|
||||
import { UserSessionRepository } from '@app/common/modules/session/repositories/session.repository';
|
||||
import { UserOtpRepository } from '@app/common/modules/user/repositories';
|
||||
import { RoleTypeRepository } from '@app/common/modules/role-type/repositories';
|
||||
import { RoleService } from 'src/role/services';
|
||||
|
||||
@Module({
|
||||
imports: [ConfigModule, UserRepositoryModule, CommonModule],
|
||||
@ -18,6 +19,7 @@ import { RoleTypeRepository } from '@app/common/modules/role-type/repositories';
|
||||
UserSessionRepository,
|
||||
UserOtpRepository,
|
||||
RoleTypeRepository,
|
||||
RoleService,
|
||||
],
|
||||
exports: [UserAuthService],
|
||||
})
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user