From e7b3540170211534f0a13784a614d6ff6802f693 Mon Sep 17 00:00:00 2001 From: evenegas Date: Fri, 3 Oct 2025 14:08:17 -0600 Subject: [PATCH 1/2] =?UTF-8?q?se=20agreg=C3=B3=20expiraci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/qr/qr-token.service.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/qr/qr-token.service.ts b/src/qr/qr-token.service.ts index 105d6a4..d045236 100644 --- a/src/qr/qr-token.service.ts +++ b/src/qr/qr-token.service.ts @@ -50,7 +50,7 @@ export class QrTokenService { console.log("fecha de caducidad:",fecha_fin); // Convert fecha_fin to seconds from now for expiresIn const expiresInSeconds = Math.floor((fecha_fin.getTime() - Date.now()) / 1000); - + console.log("expiresInSeconds:",expiresInSeconds); return this.jwtService.sign(payload, { secret, expiresIn: expiresInSeconds > 0 ? expiresInSeconds : 0, // El QR puede ser válido por 30 días @@ -69,6 +69,7 @@ export class QrTokenService { id_cuestionario: number; type: string; iat: number; + exp?: number; } | null >{ try { const secret = @@ -83,17 +84,20 @@ export class QrTokenService { where: { id_evento:decoded.id_evento }, }); - + if (!fecha_fin2) { throw new UnauthorizedException('Evento no encontrado'); } + + fecha_fin2 + const fechaFinEvento = new Date(fecha_fin2.fecha_fin); // UTC const now = new Date(); - console.log(fechaFinEvento.getTime()) - console.log(now.getTime) + console.log(fechaFinEvento) + console.log(now.getTime()) if (fechaFinEvento.getTime() < now.getTime()) { throw new Error('El evento ha finalizado'); } @@ -109,6 +113,7 @@ export class QrTokenService { id_cuestionario: decoded.id_cuestionario, type: decoded.type, iat: decoded.iat, + exp: decoded.exp, }; } catch (error) { console.error('Error validando token QR:', error.message); From 8196ea8a3118fafd541c63f1eed355d68c1495e4 Mon Sep 17 00:00:00 2001 From: evenegas Date: Fri, 3 Oct 2025 14:27:18 -0600 Subject: [PATCH 2/2] =?UTF-8?q?se=20agreg=C3=B3=20expiraci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/participante_evento/participante_evento.service.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/participante_evento/participante_evento.service.ts b/src/participante_evento/participante_evento.service.ts index f93433d..51837e9 100644 --- a/src/participante_evento/participante_evento.service.ts +++ b/src/participante_evento/participante_evento.service.ts @@ -268,10 +268,7 @@ export class ParticipanteEventoService { const tokenData = this.qrTokenService.validateQrToken(qrToken); if (!tokenData) { - throw new HttpException( - 'Token QR inválido o expirado', - HttpStatus.BAD_REQUEST, - ); + return null; } return tokenData