feat: add token validation endpoint and logic for QR token verification
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user