feat: add token validation endpoint and logic for QR token verification

This commit is contained in:
jorge miguel
2025-09-09 17:43:23 -06:00
parent 574249e09a
commit 6fc315450d
3 changed files with 22 additions and 0 deletions
@@ -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',
})
@@ -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
}
}
+2
View File
@@ -57,6 +57,8 @@ export class QrTokenService {
this.configService.get<string>('QR_JWT_SECRET') ||
this.configService.get<string>('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