find by id carrito corregido
This commit is contained in:
@@ -51,19 +51,10 @@ export class CarritoController {
|
||||
const operador: Operador = req.user.operador;
|
||||
|
||||
this.validarUsuarioService.validarAdminOperador(operador);
|
||||
return this.carritoService
|
||||
.findFullInfoById(parseInt(query.id_carrito))
|
||||
.then((carrito) => {
|
||||
if (
|
||||
operador.tipoUsuario.id_tipo_usuario > 2 &&
|
||||
operador.institucion.id_institucion !=
|
||||
carrito.modulo.institucion.id_institucion
|
||||
)
|
||||
throw new ForbiddenException(
|
||||
'No puedes acceder a esta información porque este carrito no pertenece a tu institución.',
|
||||
);
|
||||
return carrito;
|
||||
});
|
||||
return this.carritoService.findFullInfoById(
|
||||
operador,
|
||||
parseInt(query.id_carrito),
|
||||
);
|
||||
}
|
||||
|
||||
@Serealize(CarritosOutputDto)
|
||||
|
||||
@@ -153,12 +153,16 @@ export class CarritoService {
|
||||
});
|
||||
}
|
||||
|
||||
findFullInfoById(id_carrito: number): Promise<Carrito> {
|
||||
findFullInfoById(operador: Operador, id_carrito: number): Promise<Carrito> {
|
||||
return this.fullInformacionCarritoView
|
||||
.findOne({ where: { id_carrito } })
|
||||
.then((infoCarrito) => {
|
||||
if (!infoCarrito)
|
||||
throw new NotFoundException('No existe este id carrito.');
|
||||
if (operador.institucion.id_institucion != infoCarrito.id_institucion)
|
||||
throw new ForbiddenException(
|
||||
'No puedes acceder a esta información porque este carrito no pertenece a tu institución.',
|
||||
);
|
||||
return this.fullViewToCarrito(infoCarrito);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user