marca y modelo endpoints restringidos a usuario
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
ConflictException,
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Query,
|
||||
Request,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import {
|
||||
ApiBearerAuth,
|
||||
@@ -9,6 +18,7 @@ import {
|
||||
} from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { MarcaService } from './marca.service';
|
||||
import { Operador } from 'src/operador/entity/operador.entity';
|
||||
import { CreateMarcaDto } from './dto/input/create.dto';
|
||||
import { MarcaDto } from './dto/input/marca.dto';
|
||||
import { MarcaOutputDto } from './dto/output/marca.dto';
|
||||
@@ -40,7 +50,13 @@ export class MarcaController {
|
||||
description: 'Todas las variables son obligatorias.',
|
||||
examples: { ejemplo: { value: { marca: '', tipo: '' } } },
|
||||
})
|
||||
create(@Body() body: CreateMarcaDto) {
|
||||
create(@Request() req, @Body() body: CreateMarcaDto) {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException(
|
||||
'No tienes permisos para realizar esta acción.',
|
||||
);
|
||||
return this.marcaService.create(body.marca, body.tipo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user