Skip to content

Commit

Permalink
proteger rutas de post jobs/feedback/postulations
Browse files Browse the repository at this point in the history
  • Loading branch information
Crlziito04 authored and GhostRiderDev committed May 29, 2024
1 parent 04a291b commit a0d588e
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 54 deletions.
18 changes: 13 additions & 5 deletions src/feedbacks/feedbacks.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@ import {
Param,
Delete,
ParseUUIDPipe,
UseGuards,
} from '@nestjs/common';
import { FeedbacksService } from './feedbacks.service';
import { CreateFeedbackDto } from './dto/create-feedback.dto';
import { UpdateFeedbackDto } from './dto/update-feedback.dto';
import { ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { Roles } from 'src/decorators/role.decorator';
import { Role } from 'src/user/entities/Role.enum';
import { guardRoles } from 'src/guards/role.guard';
import { GuardToken } from 'src/guards/token.guard';

@Controller('feedbacks')
@ApiTags('Feedbacks')
export class FeedbacksController {
constructor(private readonly feedbacksService: FeedbacksService) {}

@ApiBearerAuth()
@Roles(Role.PROFESSIONAL, Role.CLIENT)
@UseGuards(GuardToken, guardRoles)
@Post(':id')
create(
@Body() createFeedbackDto: CreateFeedbackDto,
Expand All @@ -36,8 +44,8 @@ export class FeedbacksController {
return this.feedbacksService.findOne(id);
}

@Delete(":id")
remove(@Param("id", ParseUUIDPipe) id: string) {
return this.feedbacksService.remove(id);
}
// @Delete(":id")
// remove(@Param("id", ParseUUIDPipe) id: string) {
// return this.feedbacksService.remove(id);
// }
}
45 changes: 24 additions & 21 deletions src/jobs/jobs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ export class JobsController {
@ApiBody({
...jobApiBody,
})
//@ApiBearerAuth()
@Post()
// @Roles(Role.CLIENT)
// @UseGuards(GuardToken, guardRoles)
@ApiBearerAuth()
@Roles(Role.CLIENT)
@UseGuards(GuardToken, guardRoles)
@UseInterceptors(modifyJob)
@UseInterceptors(FileInterceptor('file'))
@UsePipes(minSizeFile)
Expand Down Expand Up @@ -174,6 +174,9 @@ export class JobsController {
return this.jobsService.findOne(id);
}

@ApiBearerAuth()
@Roles(Role.PROFESSIONAL)
@UseGuards(GuardToken, guardRoles)
@Put('finish')
finishJob(@Body() finishJob: FinishJob) {
return this.jobsService.finishJob(finishJob);
Expand All @@ -187,25 +190,25 @@ export class JobsController {
return this.jobsService.banJob(jobId);
}

@HttpCode(204)
@ApiResponse({
status: 204,
description: "Trabajo eliminado",
schema: {
example: "Trabajo con id: 5e9d7f4d-7b1f-4d6c-8e0d-4b7e6f7b1b4d eliminado",
},
})
@ApiResponse(jobNotFound)
@ApiParam(jobParamId)
@ApiOperation({
summary: "Eliminar un Trabajo por ID",
description: "Endpoint para eliminar un Trabajo por ID",
})
// @HttpCode(204)
// @ApiResponse({
// status: 204,
// description: "Trabajo eliminado",
// schema: {
// example: "Trabajo con id: 5e9d7f4d-7b1f-4d6c-8e0d-4b7e6f7b1b4d eliminado",
// },
// })
// @ApiResponse(jobNotFound)
// @ApiParam(jobParamId)
// @ApiOperation({
// summary: "Eliminar un Trabajo por ID",
// description: "Endpoint para eliminar un Trabajo por ID",
// })
// @ApiBearerAuth()
// @Roles(Role.CLIENT)
// @UseGuards(GuardToken, guardRoles)
@Delete(":id")
remove(@Param("id", ParseUUIDPipe) id: string) {
return this.jobsService.remove(id);
}
// @Delete(":id")
// remove(@Param("id", ParseUUIDPipe) id: string) {
// return this.jobsService.remove(id);
// }
}
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function bootstrap() {
'Rindoor es una plataforma que te permite encontrar a los mejores profesionales para solucionar los problemas de tu hogar.',
)
.setVersion('1.0')
//.addBearerAuth()
.addBearerAuth()
.build();
const document = SwaggerModule.createDocument(app, configSwagger);
SwaggerModule.setup('api', app, document);
Expand Down
57 changes: 30 additions & 27 deletions src/postulations/postulations.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export class PostulationsController {
summary: 'Crear postulación',
description: 'Crea una postulación a un trabajo',
})
// @ApiBearerAuth()
// @Roles(Role.PROFESSIONAL)
// @UseGuards(GuardToken, guardRoles)
@ApiBearerAuth()
@Roles(Role.PROFESSIONAL)
@UseGuards(GuardToken, guardRoles)
@Post()
@UseInterceptors(modifyPostulation)
create(@Body() createPostulationDto: CreatePostulationDto) {
Expand Down Expand Up @@ -115,31 +115,34 @@ export class PostulationsController {
return this.postulationsService.findOne(id);
}

@HttpCode(204)
@ApiResponse({
status: 204,
description: "Postulación eliminada",
schema: {
example: {
message: `Postulacion con id: ${exampleCreatedPostulation.id} eliminada`,
},
},
})
@ApiResponse(postulationNotFound)
@ApiResponse(accessOnlyProfessional)
@ApiParam(postulationApiParam)
@ApiOperation({
summary: "Eliminar postulación",
description: "Elimina una postulación por su id",
})
@Delete(":id")
// @ApiBearerAuth()
// @Roles(Role.PROFESSIONAL)
// @UseGuards(GuardToken, guardRoles)
remove(@Param("id") id: string) {
return this.postulationsService.remove(id);
}
// @HttpCode(204)
// @ApiResponse({
// status: 204,
// description: "Postulación eliminada",
// schema: {
// example: {
// message: `Postulacion con id: ${exampleCreatedPostulation.id} eliminada`,
// },
// },
// })
// @ApiResponse(postulationNotFound)
// @ApiResponse(accessOnlyProfessional)
// @ApiParam(postulationApiParam)
// @ApiOperation({
// summary: "Eliminar postulación",
// description: "Elimina una postulación por su id",
// })
// @Delete(":id")
// // @ApiBearerAuth()
// // @Roles(Role.PROFESSIONAL)
// // @UseGuards(GuardToken, guardRoles)
// remove(@Param("id") id: string) {
// return this.postulationsService.remove(id);
// }

@ApiBearerAuth()
@Roles(Role.CLIENT)
@UseGuards(GuardToken, guardRoles)
@Put('close')
closePostulationByClient(@Body() closePostulation: ClosePostulation) {
return this.postulationsService.closePostulationByClient(closePostulation);
Expand Down

0 comments on commit a0d588e

Please sign in to comment.