qr
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -45,9 +45,7 @@ export class QrTokenService {
|
||||
this.configService.get<string>('QR_JWT_SECRET') ||
|
||||
this.configService.get<string>('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<string>('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;
|
||||
|
||||
Reference in New Issue
Block a user