fix(security): add RolesGuard to doctors mutations and JwtAuthGuard to prescriptions upload
This commit is contained in:
1 parent
efb3c473c4
commit
11dd549c7c
2 files changed
+12
-3
No files matched your search
@@ -13,6 +13,8 @@ import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { DoctorsService } from './doctors.service';
|
||||
import { DoctorQueryDto } from './dto/doctor-query.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
import { Roles } from '../common/decorators/roles.decorator';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
@ApiTags('Doctors')
|
||||
@@ -33,7 +35,8 @@ export class DoctorsController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin', 'ADMIN')
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Create new doctor' })
|
||||
create(@Body() createDoctorDto: Prisma.DoctorCreateInput) {
|
||||
@@ -41,7 +44,8 @@ export class DoctorsController {
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin', 'ADMIN')
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Update doctor' })
|
||||
update(
|
||||
@@ -52,7 +56,8 @@ export class DoctorsController {
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin', 'ADMIN')
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'Delete doctor' })
|
||||
remove(@Param('id') id: string) {
|
||||
|
||||
@@ -46,6 +46,8 @@ export class PrescriptionsController {
|
||||
private readonly mediaService: MediaService,
|
||||
) {}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post('upload')
|
||||
@ApiOperation({ summary: 'آپلود تصویر یا فایل نسخه دارویی توسط کاربر' })
|
||||
@UseInterceptors(
|
||||
@@ -72,6 +74,8 @@ export class PrescriptionsController {
|
||||
return { success: true, data };
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'بارگذاری نسخه جدید توسط کاربر' })
|
||||
create(
|
||||
|
||||
Reference in new issue
Block a user