From f346da673b469c09486d199d680caf7988b32aa1 Mon Sep 17 00:00:00 2001 From: evenegas Date: Wed, 1 Oct 2025 12:00:14 -0600 Subject: [PATCH] qr --- .../cuestionario_respondido.service.ts | 2 -- src/qr/qr-token.service.ts | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cuestionario_respondido/cuestionario_respondido.service.ts b/src/cuestionario_respondido/cuestionario_respondido.service.ts index 0de8073..0f8d78a 100644 --- a/src/cuestionario_respondido/cuestionario_respondido.service.ts +++ b/src/cuestionario_respondido/cuestionario_respondido.service.ts @@ -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); diff --git a/src/qr/qr-token.service.ts b/src/qr/qr-token.service.ts index 6c8c1f6..5e8b934 100644 --- a/src/qr/qr-token.service.ts +++ b/src/qr/qr-token.service.ts @@ -45,9 +45,7 @@ export class QrTokenService { this.configService.get('QR_JWT_SECRET') || this.configService.get('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('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;