usuario operador prestamo y upload falta validación
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
Body,
|
||||
ConflictException,
|
||||
ForbiddenException,
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { InstitucionProgramaService } from './institucion-programa.service';
|
||||
import { Operador } from 'src/operador/entity/operador.entity';
|
||||
import { Usuario } from 'src/usuario/entity/usuario.entity';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { CreateProgramaDto } from './dto/input/create.dto';
|
||||
import { UpdateProgramaDto } from './dto/input/update.dto';
|
||||
@@ -44,7 +45,7 @@ export class InstitucionProgramaController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
if (!superAdmin || superAdmin.tipoUsuario.id_tipo_usuario != 2)
|
||||
throw new ConflictException(
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para realizar esta acción.',
|
||||
);
|
||||
return this.institucionProgramaService.create(body.programa);
|
||||
@@ -55,7 +56,18 @@ export class InstitucionProgramaController {
|
||||
@UseGuards(AuthGuard('jwt'))
|
||||
@ApiOperation({ description: 'Endpoint que retorna todos los programas.' })
|
||||
@ApiBearerAuth('jwt')
|
||||
get() {
|
||||
get(@Request() req) {
|
||||
const operador: Operador = req.user.operador;
|
||||
|
||||
if (
|
||||
!operador ||
|
||||
(operador.tipoUsuario.id_tipo_usuario != 2 &&
|
||||
operador.tipoUsuario.id_tipo_usuario != 3 &&
|
||||
operador.tipoUsuario.id_tipo_usuario != 4)
|
||||
)
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para realizar esta acción.',
|
||||
);
|
||||
return this.institucionProgramaService.findAllProgramas();
|
||||
}
|
||||
|
||||
@@ -71,7 +83,13 @@ export class InstitucionProgramaController {
|
||||
name: 'id_institucion',
|
||||
type: 'string',
|
||||
})
|
||||
programas(@Query() query: IdInstitucionDto) {
|
||||
programas(@Request() req, @Query() query: IdInstitucionDto) {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para acceder a esta información.',
|
||||
);
|
||||
return this.institucionProgramaService.findAllByIdInstitucion(
|
||||
parseInt(query.id_institucion),
|
||||
);
|
||||
@@ -90,7 +108,13 @@ export class InstitucionProgramaController {
|
||||
name: 'id_institucion',
|
||||
type: 'string',
|
||||
})
|
||||
programasMostrar(@Query() query: IdInstitucionDto) {
|
||||
programasMostrar(@Request() req, @Query() query: IdInstitucionDto) {
|
||||
const usuario: Usuario = req.user.usuario;
|
||||
|
||||
if (!usuario)
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para acceder a esta información.',
|
||||
);
|
||||
return this.institucionProgramaService.findAllByIdInstitucion(
|
||||
parseInt(query.id_institucion),
|
||||
true,
|
||||
@@ -114,7 +138,7 @@ export class InstitucionProgramaController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
if (!admin || admin.tipoUsuario.id_tipo_usuario != 3)
|
||||
throw new ConflictException(
|
||||
throw new ForbiddenException(
|
||||
'No tienes los permisos necesarios para realizar esta acción.',
|
||||
);
|
||||
return this.institucionProgramaService.update(admin, body);
|
||||
|
||||
Reference in New Issue
Block a user