Skip to content
Snippets Groups Projects
Commit 86d62550 authored by Martin Korec's avatar Martin Korec
Browse files

fix: used UseGuards decorator with AuthorizationGuard for POST, PATCH and...

fix: used UseGuards decorator with AuthorizationGuard for POST, PATCH and DELETE requests in CategoriesController
parent d6668119
No related branches found
No related tags found
No related merge requests found
...@@ -5,19 +5,21 @@ import { ...@@ -5,19 +5,21 @@ import {
Body, Body,
Patch, Patch,
Param, Param,
Delete, Delete, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { CategoriesService } from './categories.service'; import { CategoriesService } from './categories.service';
import { CreateCategoryDto } from './dto/create-category.dto'; import { CreateCategoryDto } from './dto/create-category.dto';
import { UpdateCategoryDto } from './dto/update-category.dto'; import { UpdateCategoryDto } from './dto/update-category.dto';
import { CategoryEntity } from './entities/category.entity'; import { CategoryEntity } from './entities/category.entity';
import {AuthorizationGuard} from "../../authorization/authorization.guard";
@ApiTags('categories') @ApiTags('categories')
@Controller('categories') @Controller('categories')
export class CategoriesController { export class CategoriesController {
constructor(private readonly categoriesService: CategoriesService) {} constructor(private readonly categoriesService: CategoriesService) {}
@UseGuards(AuthorizationGuard)
@Post() @Post()
async create( async create(
@Body() createCategoryDto: CreateCategoryDto, @Body() createCategoryDto: CreateCategoryDto,
...@@ -35,6 +37,7 @@ export class CategoriesController { ...@@ -35,6 +37,7 @@ export class CategoriesController {
return await this.categoriesService.findOne(id); return await this.categoriesService.findOne(id);
} }
@UseGuards(AuthorizationGuard)
@Patch(':id') @Patch(':id')
async update( async update(
@Param('id') id: string, @Param('id') id: string,
...@@ -43,6 +46,7 @@ export class CategoriesController { ...@@ -43,6 +46,7 @@ export class CategoriesController {
return await this.categoriesService.update(id, updateCategoryDto); return await this.categoriesService.update(id, updateCategoryDto);
} }
@UseGuards(AuthorizationGuard)
@Delete(':id') @Delete(':id')
async remove(@Param('id') id: string): Promise<CategoryEntity> { async remove(@Param('id') id: string): Promise<CategoryEntity> {
return await this.categoriesService.remove(id); return await this.categoriesService.remove(id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment