This commit is contained in:
evenegas
2025-10-01 12:00:14 -06:00
parent 8690c82429
commit f346da673b
2 changed files with 14 additions and 6 deletions
@@ -116,7 +116,6 @@ export class CuestionarioRespondidoService {
participante.id_participante,
cuestionario.evento.id_evento,
cuestionario.id_cuestionario,
);
// Generar código QR con el token
@@ -341,7 +340,6 @@ export class CuestionarioRespondidoService {
participante.id_participante,
cuestionario.evento.id_evento,
cuestionario.id_cuestionario,
);
qrBuffer = await QRCode.toBuffer(qrToken);
+14 -4
View File
@@ -45,9 +45,7 @@ export class QrTokenService {
this.configService.get<string>('QR_JWT_SECRET') ||
this.configService.get<string>('JWT_SECRET', 'tu_clave_secreta');
const fecha_fin = await this.cuestionarioRepository.findOne({
where: { id_cuestionario },
});
const fecha_fin2 = await this.eventoREpo.findOne({
where: { id_evento },
@@ -84,9 +82,21 @@ export class QrTokenService {
this.configService.get<string>('JWT_SECRET', 'tu_clave_secreta');
console.log(secret)
const decoded = this.jwtService.verify(token, { secret });
const fecha_fin2 = await this.eventoREpo.findOne({
where: { id_evento:decoded.id_evento },
});
if (!fecha_fin2) {
throw new UnauthorizedException('Evento no encontrado');
}
const now = new Date();
if (fecha_fin2.fecha_fin < now) {
throw new Error('El evento ha finalizado');
}
// Verificar que sea un token de tipo QR de asistencia
if (decoded.type !== 'qr_asistencia') {
return null;