Seguridaad

This commit is contained in:
mike
2024-07-24 14:34:01 -06:00
parent ff158b0d32
commit f5ae636a7f
2 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -40,4 +40,4 @@ import {
return this.comentariosService.deleteComentario(id);
}
}
+12 -3
View File
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { BadRequestException, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Comentarios } from './entity/comentarios.entity';
import { Repository } from 'typeorm';
@@ -12,6 +12,11 @@ export class ComentariosService {
) {}
postComentario(comentario: ComentarioDto) {
if (comentario.from !== 'CEDETEC' && comentario.from !== 'PCPUMA') {
throw new BadRequestException('Mensaje no autorizado');
}
const nuevoComentario = this.comentariosRepository.create(comentario);
return this.comentariosRepository.save(nuevoComentario);
}
@@ -35,11 +40,15 @@ export class ComentariosService {
}
if (after) {
query.andWhere('comentarios.fecha_registro > :after', { after: new Date(after) });
query.andWhere('comentarios.fecha_registro > :after', {
after: new Date(after),
});
}
if (from) {
query.andWhere('comentarios.fecha_registro >= :from', { from: new Date(from) });
query.andWhere('comentarios.fecha_registro >= :from', {
from: new Date(from),
});
}
if (to) {