diff --git a/src/participante_evento/participante_evento.controller.ts b/src/participante_evento/participante_evento.controller.ts index df24753..bc450cb 100644 --- a/src/participante_evento/participante_evento.controller.ts +++ b/src/participante_evento/participante_evento.controller.ts @@ -233,6 +233,12 @@ export class ParticipanteEventoController { ); } + @Post('decode-token') + decodeToken(@Body() body: { token: string }) { + return this.participanteEventoService.validToken( + body.token, + ); + } @ApiOperation({ summary: 'Registrar asistencia usando token QR', }) diff --git a/src/participante_evento/participante_evento.service.ts b/src/participante_evento/participante_evento.service.ts index 205fce9..cbb2dab 100644 --- a/src/participante_evento/participante_evento.service.ts +++ b/src/participante_evento/participante_evento.service.ts @@ -260,4 +260,18 @@ export class ParticipanteEventoService { }, }; } + + async validToken(qrToken: string) { + // Validar el token QR + const tokenData = this.qrTokenService.validateQrToken(qrToken); + + if (!tokenData) { + throw new HttpException( + 'Token QR inválido o expirado', + HttpStatus.BAD_REQUEST, + ); + } + + return tokenData + } } diff --git a/src/qr/qr-token.service.ts b/src/qr/qr-token.service.ts index f0792e1..e5243c4 100644 --- a/src/qr/qr-token.service.ts +++ b/src/qr/qr-token.service.ts @@ -57,6 +57,8 @@ export class QrTokenService { this.configService.get('QR_JWT_SECRET') || this.configService.get('JWT_SECRET', 'tu_clave_secreta'); + console.log(secret) + const decoded = this.jwtService.verify(token, { secret }); // Verificar que sea un token de tipo QR de asistencia