qr
This commit is contained in:
@@ -116,7 +116,6 @@ export class CuestionarioRespondidoService {
|
||||
participante.id_participante,
|
||||
cuestionario.evento.id_evento,
|
||||
cuestionario.id_cuestionario,
|
||||
cuestionario.fecha_fin
|
||||
);
|
||||
|
||||
// Generar código QR con el token
|
||||
@@ -341,7 +340,6 @@ export class CuestionarioRespondidoService {
|
||||
participante.id_participante,
|
||||
cuestionario.evento.id_evento,
|
||||
cuestionario.id_cuestionario,
|
||||
cuestionario.fecha_fin
|
||||
);
|
||||
|
||||
qrBuffer = await QRCode.toBuffer(qrToken);
|
||||
|
||||
@@ -31,7 +31,6 @@ export class QrTokenService {
|
||||
id_participante: number,
|
||||
id_evento: number,
|
||||
id_cuestionario: number,
|
||||
fecha_fin: Date,
|
||||
): string {
|
||||
const payload = {
|
||||
id_participante,
|
||||
@@ -51,11 +50,11 @@ export class QrTokenService {
|
||||
|
||||
|
||||
// Convert fecha_fin to seconds from now for expiresIn
|
||||
const expiresInSeconds = Math.floor((fecha_fin.getTime() - Date.now()) / 1000);
|
||||
|
||||
|
||||
return this.jwtService.sign(payload, {
|
||||
secret,
|
||||
expiresIn: expiresInSeconds > 0 ? expiresInSeconds : 0, // El QR puede ser válido por 30 días
|
||||
expiresIn: "30d", // El QR puede ser válido por 30 días
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,23 +69,21 @@ export class QrController {
|
||||
};
|
||||
}
|
||||
|
||||
@Get('generate-token/:idParticipante/:idEvento/:idCuestionario/:fechaFin')
|
||||
@Get('generate-token/:idParticipante/:idEvento/:idCuestionario')
|
||||
@ApiOperation({ summary: 'Genera un token JWT para QR de asistencia' })
|
||||
@ApiParam({ name: 'idParticipante', description: 'ID del participante' })
|
||||
@ApiParam({ name: 'idEvento', description: 'ID del evento' })
|
||||
@ApiParam({ name: 'idCuestionario', description: 'ID del cuestionario' })
|
||||
@ApiParam({ name: 'fechaFin', description: 'Fecha de fin de validez del token (ISO 8601)' })
|
||||
|
||||
async generateQrToken(
|
||||
@Param('idParticipante', ParseIntPipe) idParticipante: number,
|
||||
@Param('idEvento', ParseIntPipe) idEvento: number,
|
||||
@Param('idCuestionario', ParseIntPipe) idCuestionario: number,
|
||||
@Param('fechaFin') fechaFin: Date,
|
||||
) {
|
||||
const token = await this.qrTokenService.generateQrToken(
|
||||
const token = this.qrTokenService.generateQrToken(
|
||||
idParticipante,
|
||||
idEvento,
|
||||
idCuestionario,
|
||||
fechaFin
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user