mirror of
https://github.com/SyncrowIOT/backend.git
synced 2026-10-27 05:27:54 +00:00
Update role guards to differentiate between admin and super admin roles
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
import { RoleService } from '../services/role.service';
|
||||
import { UserRoleEditDto } from '../dtos';
|
||||
import { AdminRoleGuard } from 'src/guards/admin.role.guard';
|
||||
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
||||
|
||||
@ApiTags('Role Module')
|
||||
@Controller({
|
||||
@@ -21,7 +21,7 @@ import { AdminRoleGuard } from 'src/guards/admin.role.guard';
|
||||
export class RoleController {
|
||||
constructor(private readonly roleService: RoleService) {}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AdminRoleGuard)
|
||||
@UseGuards(SuperAdminRoleGuard)
|
||||
@Get('types')
|
||||
async fetchRoleTypes() {
|
||||
try {
|
||||
@@ -36,7 +36,7 @@ export class RoleController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AdminRoleGuard)
|
||||
@UseGuards(SuperAdminRoleGuard)
|
||||
@Put('edit/user/:userUuid')
|
||||
async editUserRoleType(
|
||||
@Param('userUuid') userUuid: string,
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { RoleType } from '@app/common/constants/role.type.enum';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { IsEnum } from 'class-validator';
|
||||
import { IsEnum, IsIn } from 'class-validator';
|
||||
|
||||
export class UserRoleEditDto {
|
||||
@ApiProperty({
|
||||
description: 'role type',
|
||||
enum: RoleType,
|
||||
description: 'Role type (USER or ADMIN)',
|
||||
enum: [RoleType.USER, RoleType.ADMIN],
|
||||
required: true,
|
||||
})
|
||||
@IsEnum(RoleType)
|
||||
@IsIn([RoleType.USER, RoleType.ADMIN], {
|
||||
message: 'roleType must be one of the following values: USER, ADMIN',
|
||||
})
|
||||
roleType: RoleType;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user