Merge branch 'develop' of https://repositorio.acatlan.unam.mx/CIDWA/formularios_api into develop
This commit is contained in:
@@ -268,10 +268,7 @@ export class ParticipanteEventoService {
|
|||||||
const tokenData = this.qrTokenService.validateQrToken(qrToken);
|
const tokenData = this.qrTokenService.validateQrToken(qrToken);
|
||||||
|
|
||||||
if (!tokenData) {
|
if (!tokenData) {
|
||||||
throw new HttpException(
|
return null;
|
||||||
'Token QR inválido o expirado',
|
|
||||||
HttpStatus.BAD_REQUEST,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokenData
|
return tokenData
|
||||||
|
|||||||
+23
-22
@@ -50,7 +50,7 @@ export class QrTokenService {
|
|||||||
console.log("fecha de caducidad:",fecha_fin);
|
console.log("fecha de caducidad:",fecha_fin);
|
||||||
// Convert fecha_fin to seconds from now for expiresIn
|
// Convert fecha_fin to seconds from now for expiresIn
|
||||||
const expiresInSeconds = Math.floor((fecha_fin.getTime() - Date.now()) / 1000);
|
const expiresInSeconds = Math.floor((fecha_fin.getTime() - Date.now()) / 1000);
|
||||||
|
console.log("expiresInSeconds:",expiresInSeconds);
|
||||||
console.log("Caducidad token: ", Math.floor((fecha_fin.getTime() - Date.now()) / 1000));
|
console.log("Caducidad token: ", Math.floor((fecha_fin.getTime() - Date.now()) / 1000));
|
||||||
|
|
||||||
return this.jwtService.sign(payload, {
|
return this.jwtService.sign(payload, {
|
||||||
@@ -71,6 +71,7 @@ export class QrTokenService {
|
|||||||
id_cuestionario: number;
|
id_cuestionario: number;
|
||||||
type: string;
|
type: string;
|
||||||
iat: number;
|
iat: number;
|
||||||
|
exp?: number;
|
||||||
} | null >{
|
} | null >{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -88,34 +89,34 @@ export class QrTokenService {
|
|||||||
const fecha_fin2 = await this.eventoREpo.findOne({
|
const fecha_fin2 = await this.eventoREpo.findOne({
|
||||||
where: { id_evento:decoded.id_evento },
|
where: { id_evento:decoded.id_evento },
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!fecha_fin2) {
|
|
||||||
throw new UnauthorizedException('Evento no encontrado');
|
|
||||||
}
|
|
||||||
const fechaFinEvento = new Date(fecha_fin2.fecha_fin); // UTC
|
if (!fecha_fin2) {
|
||||||
const now = new Date();
|
throw new UnauthorizedException('Evento no encontrado');
|
||||||
console.log("Fecha fin cruda (de DB):", fecha_fin2.fecha_fin);
|
}
|
||||||
console.log("Fecha fin convertida:", fechaFinEvento.toISOString());
|
const fechaFinEvento = new Date(fecha_fin2.fecha_fin); // UTC
|
||||||
console.log("Fecha fin timestamp:", fechaFinEvento.getTime());
|
const now = new Date();
|
||||||
console.log("Fecha actual:", now.toISOString());
|
console.log(fechaFinEvento.getTime())
|
||||||
console.log("Fecha actual timestamp:", now.getTime());
|
console.log(now.getTime)
|
||||||
if (fechaFinEvento.getTime() < now.getTime()) {
|
if (fechaFinEvento.getTime() < now.getTime()) {
|
||||||
throw new Error('El evento ha finalizado');
|
throw new Error('El evento ha finalizado');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar que sea un token de tipo QR de asistencia
|
// Verificar que sea un token de tipo QR de asistencia
|
||||||
if (decoded.type !== 'qr_asistencia') {
|
if (decoded.type !== 'qr_asistencia') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id_participante: decoded.id_participante,
|
id_participante: decoded.id_participante,
|
||||||
id_evento: decoded.id_evento,
|
id_evento: decoded.id_evento,
|
||||||
id_cuestionario: decoded.id_cuestionario,
|
id_cuestionario: decoded.id_cuestionario,
|
||||||
type: decoded.type,
|
type: decoded.type,
|
||||||
iat: decoded.iat,
|
iat: decoded.iat,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error validando token QR:', error.message);
|
console.error('Error validando token QR:', error.message);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user