mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
auth permission guard added
This commit is contained in:
@ -19,6 +19,8 @@ import {
|
||||
GetDeviceByRoomIdDto,
|
||||
} from '../dtos/get.device.dto';
|
||||
import { ControlDeviceDto } from '../dtos/control.device.dto';
|
||||
import { AuthGuardWithRoles } from 'src/guards/device.permission.guard';
|
||||
import { PermissionType } from '@app/common/constants/permission-type.enum';
|
||||
|
||||
@ApiTags('Device Module')
|
||||
@Controller({
|
||||
@ -29,7 +31,7 @@ export class DeviceController {
|
||||
constructor(private readonly deviceService: DeviceService) {}
|
||||
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.READ)
|
||||
@Get('room')
|
||||
async getDevicesByRoomId(
|
||||
@Query() getDeviceByRoomIdDto: GetDeviceByRoomIdDto,
|
||||
@ -41,7 +43,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.READ)
|
||||
@Get('group')
|
||||
async getDevicesByGroupId(
|
||||
@Query() getDeviceByGroupIdDto: GetDeviceByGroupIdDto,
|
||||
@ -55,7 +57,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.READ)
|
||||
@Get(':deviceId')
|
||||
async getDeviceDetailsByDeviceId(@Param('deviceId') deviceId: string) {
|
||||
try {
|
||||
@ -65,7 +67,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.READ)
|
||||
@Get(':deviceId/functions')
|
||||
async getDeviceInstructionByDeviceId(@Param('deviceId') deviceId: string) {
|
||||
try {
|
||||
@ -75,7 +77,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.READ)
|
||||
@Get(':deviceId/functions/status')
|
||||
async getDevicesInstructionStatus(@Param('deviceId') deviceId: string) {
|
||||
try {
|
||||
@ -85,7 +87,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.CONTROLLABLE)
|
||||
@Post('room')
|
||||
async addDeviceInRoom(@Body() addDeviceInRoomDto: AddDeviceInRoomDto) {
|
||||
try {
|
||||
@ -95,7 +97,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.CONTROLLABLE)
|
||||
@Post('group')
|
||||
async addDeviceInGroup(@Body() addDeviceInGroupDto: AddDeviceInGroupDto) {
|
||||
try {
|
||||
@ -105,7 +107,7 @@ export class DeviceController {
|
||||
}
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@AuthGuardWithRoles(PermissionType.CONTROLLABLE)
|
||||
@Post('control')
|
||||
async controlDevice(@Body() controlDeviceDto: ControlDeviceDto) {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user