utn-cli 2.0.41 → 2.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utn-cli",
3
- "version": "2.0.41",
3
+ "version": "2.0.42",
4
4
  "description": "Herramienta CLI unificada para la gestión de plantillas en SIGU.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,13 +23,30 @@ Router.get('/funcionDeEjemplo', async (solicitud, respuesta, next) => {
23
23
  }
24
24
  });
25
25
 
26
+ // Router.post('/cargarArchivo/:Etiquetas', async (solicitud, respuesta, next) => {
27
+ // try {
28
+ // if (await Miscelaneo.validarTokenV2(solicitud.headers.authorization) && await Miscelaneo.validarAccesoDelOrigen(solicitud)) {
29
+ // try {
30
+ // return respuesta.json({ body: await Servicio1.cargarArchivo(solicitud, solicitud.params.Etiquetas), error: undefined });
31
+ // } catch (error) {
32
+ // const MensajeDeError = 'No fue posible cargar el archivo';
33
+ // console.error(new ManejadorDeErrores(MensajeDeError, ManejadorDeErrores.obtenerNumeroDeLinea(), true, `Dirección IP: ${solicitud.ip}`));
34
+ // return respuesta.status(500).json({ body: undefined, error: MensajeDeError });
35
+ // }
36
+ // }
37
+ // return respuesta.status(401).json({ body: undefined, error: ManejadorDeErrores.mensajeDeError401() });
38
+ // } catch (error) {
39
+ // next(error);
40
+ // }
41
+ // });
42
+
26
43
  // Router.get('/listarArchivosExterno/:Etiquetas', async (solicitud, respuesta, next) => {
27
44
  // try {
28
45
  // if (await Miscelaneo.validarTokenV2(solicitud.headers.authorization) && await Miscelaneo.validarAccesoDelOrigen(solicitud)) {
29
46
  // try {
30
47
  // const Datos = { Etiquetas: solicitud.params.Etiquetas };
31
48
  // Datos.Token = solicitud.headers.authorization;
32
- // return respuesta.json({ body: await Miscelaneo.listarArchivosExterno(Datos), error: undefined });
49
+ // return respuesta.json({ body: await Servicio1.listarArchivosExterno(Datos), error: undefined });
33
50
  // } catch (error) {
34
51
  // const MensajeDeError = 'No fue posible obtener los arcvhivos';
35
52
  // console.error(new ManejadorDeErrores(MensajeDeError, ManejadorDeErrores.obtenerNumeroDeLinea(), true, `Dirección IP: ${solicitud.ip}`));
@@ -427,8 +427,31 @@ class Miscelaneo {
427
427
  SELECT COUNT(*) AS Total \
428
428
  FROM `SIGU`.`SIGU_DireccionesUsadasPorLosUsuarios` \
429
429
  WHERE `Identificador` = ? AND `DireccionUsadaPorElUsuario` = ?", [Identificador, ipUsuario]);
430
+
431
+ // Verificar si la fecha de cambio supera los 2 meses
432
+ const fechaUltimoCambio = await ConexionSigu.query(
433
+ "SELECT LastUpdate \
434
+ FROM `SIGU`.`SIGU_FechaDelUltimoCambioDeClave` \
435
+ WHERE `Identificador` = ?",
436
+ [Identificador]
437
+ );
438
+ let fechaBD = fechaUltimoCambio?.[0]?.[0]?.LastUpdate;
439
+ const fechaUltimo = new Date(fechaBD);
440
+ const fechaActual = new Date();
441
+ const diferenciaMs = fechaActual - fechaUltimo;
442
+ const diasPasados = diferenciaMs / (1000 * 60 * 60 * 24);
443
+ if (!fechaBD || diasPasados >= 60) {
444
+ await ConexionSigu.query(
445
+ "UPDATE`SIGU_Personas` \
446
+ SET`Clave` = '' \
447
+ where`Identificador` = ? ;",
448
+ [Identificador]
449
+ );
450
+ return { RequiereCambioContraseña: true };
451
+
452
+ }
453
+
430
454
  if (ipExiste[0][0].Total === 0) {
431
- console.log("IP nueva detectada para el usuario, iniciando 2FA");
432
455
  // GENERAR CODIGO 2FA
433
456
  let Codigo2FA = await ConexionSigu.query("SELECT UUID() AS `Dato`");
434
457
  Codigo2FA = Codigo2FA[0][0].Dato;
@@ -449,7 +472,6 @@ class Miscelaneo {
449
472
  WHERE `Identificador` = ? \
450
473
  AND `Principal` = TRUE"
451
474
  , [Identificador]);
452
-
453
475
  // ENVIAR CORREO
454
476
  await envioDeCorreo(
455
477
  CorreoElectronico[0][0].CorreoElectronico,
@@ -460,6 +482,7 @@ class Miscelaneo {
460
482
  "<p>Si usted no inició este proceso, puede ignorar este mensaje.</p>"
461
483
  );
462
484
  return { Requiere2FA: true };
485
+
463
486
  }
464
487
 
465
488
  // SI LA IP YA EXISTE CONTINUA
@@ -473,18 +496,16 @@ class Miscelaneo {
473
496
  LastUser,
474
497
  LastUser
475
498
  ]);
476
- return { Token, Dominio: ((process.env.ENV || 'local') === 'production' ? '.sigu.utn.ac.cr' : '-') };
499
+ return { Token, Dominio: ((process.env.ENV || 'local') === 'production' ? '.sigu.utn.ac.cr' : '.181.193.85.44.nip.io') };
477
500
 
478
501
  } else {
479
502
  console.log("La clave brindada para el usuario", Solicitud.body.Identificacion, "no conincide");
480
-
481
503
  const Resultados2 = await ConexionSigu.query("SELECT COUNT(*) AS `Total` FROM `SIGU`.`SIGU_ClavesTemporalesDeLasPersonas` WHERE `Identificador` = ? AND `Clave` = ?", [Identificador, Solicitud.body.Clave]);
482
-
483
504
  if (Resultados2[0][0]['Total'] > 0) {
484
505
  console.log("La clave brindada para el usuario", Solicitud.body.Identificacion, "no conincide, pero coincide la clave temporal");
485
506
  await ConexionSigu.query("UPDATE `SIGU`.`SIGU_Personas` SET `Clave` = ?, `LastUpdate` = NOW(4), `LastUser` = ? WHERE `Identificacion` = ?"
486
507
  , [await bcrypt.hash(require('crypto').createHash('md5').update(Solicitud.body.Clave).digest("hex"), 10), LastUser, Solicitud.body.Identificacion]);
487
-
508
+ await ConexionSigu.query("REPLACE INTO `SIGU`.`SIGU_FechaDelUltimoCambioDeClave` VALUES (?, NOW(), ?);", [Identificador, LastUser]);
488
509
  await ConexionSigu.query("DELETE FROM `SIGU`.`SIGU_ClavesTemporalesDeLasPersonas`WHERE `Identificador` = ?", [Identificador]);
489
510
  return await this.Autenticar(Solicitud);
490
511
 
@@ -17,6 +17,35 @@ class Servicio1 {
17
17
  return ejecutarConsulta("SELECT ?", [ParametroDeEjemplo]);
18
18
  }
19
19
 
20
+ // async cargarArchivo(Solicitud, Etiquetas) {
21
+ // const Partes = Etiquetas.split('--');
22
+ // Etiquetas = Partes.slice(0, -1).join("--");
23
+ // let Resultado = undefined;
24
+ // try {
25
+ // Resultado = await this.obtenerDatosDelUsuario(Solicitud.headers.authorization);
26
+ // } catch (error) {
27
+ // console.error(error);
28
+ // }
29
+ // // Validación del token para el usuario y authorización
30
+ // if (Resultado) {
31
+ // const informacionDelArchivo = await this.almacenarArchivoEnDisco(Solicitud, Resultado['uid']);
32
+ // const Respuesta = await ejecutarConsultaSIGU("INSERT INTO `SIGU`.`SIGU_Adjuntos` (`AdjuntosId`, `Identificador`, `Modulo`, `Seccion`, `Nombre`,\
33
+ // `NombreOriginal`, `Ruta`, `Tipo`, `Tamanio`, `Etiqueta`, `LastUpdate`, `LastUser`)\
34
+ // VALUES (NULL, ?, ?, 'No aplica', ?, ?, ?, ?, ?, 'No aplica', NOW(4), ?)"
35
+ // , [Resultado['uid'], this.NombreCanonicoDelModulo, informacionDelArchivo.nombreDeArchivo, informacionDelArchivo.nombreDeArchivo
36
+ // , informacionDelArchivo.rutaDeArchivo, informacionDelArchivo.tipoDeContenido, informacionDelArchivo.tamanioTotal
37
+ // , Resultado['uid']]);
38
+ // informacionDelArchivo.insertId = Respuesta.insertId;
39
+ // informacionDelArchivo.Etiquetas = Etiquetas;
40
+ // await ejecutarConsulta("INSERT INTO `" + this.NombreDelRepositorioDeLaBaseDeDatos.slice(0, -3) + "`.`Archivos`\
41
+ // VALUES (?, ?, ?, ?, ?, NOW(4), ?)"
42
+ // , [Respuesta.insertId, Resultado.uid, informacionDelArchivo.rutaDeArchivo, informacionDelArchivo.nombreDeArchivo
43
+ // , Etiquetas, Resultado.uid]);
44
+ // return informacionDelArchivo;
45
+ // }
46
+ // return;
47
+ // }
48
+
20
49
  // async listar() {
21
50
  // return await ejecutarConsulta("SELECT `BeneficioEstudiantilId`, `Nombre`, `Tipo`, `Estado` FROM `vve-bybe`.`BYBE_BeneficiosEstudiantiles`");
22
51
  // }
@@ -4,6 +4,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
4
4
  import { HttpClient, HttpHeaders } from '@angular/common/http';
5
5
  import { MatIconModule } from '@angular/material/icon';
6
6
  import { DatosGlobalesService } from '../../../datos-globales.service';
7
+ import { MensajeConfirmacionComponent } from '../mensaje-confirmacion/mensaje-confirmacion';
8
+ import { MatDialog } from '@angular/material/dialog';
7
9
 
8
10
  @Component({
9
11
  selector: 'app-subir-archivo',
@@ -24,7 +26,8 @@ export class SubirArchivoComponent implements OnInit {
24
26
  Token: any;
25
27
  public RutaParaListar: string = 'misc/listarArchivos/';
26
28
  public RutaParaDescargar: string = 'misc/descargarArchivo/';
27
- constructor(private datosGlobalesService: DatosGlobalesService, private http: HttpClient) { }
29
+ public RutaParaCargar: string = 'misc/cargarArchivo/';
30
+ constructor(private dialog: MatDialog, private datosGlobalesService: DatosGlobalesService, private http: HttpClient) { }
28
31
 
29
32
  ngOnInit(): void {
30
33
  if (this.data.RutaParaListar) {
@@ -61,7 +64,15 @@ export class SubirArchivoComponent implements OnInit {
61
64
  if (this.ValidarFormato(archivoArrastrado)) {
62
65
  this.Archivo = archivoArrastrado;
63
66
  } else {
64
- alert('Formato de archivo no permitido. Los formatos permitidos son: ' + this.FormatosPermitidos.join(', '));
67
+ this.dialog.open(MensajeConfirmacionComponent, {
68
+ data: {
69
+ titulo: 'Formato de archivo incorrecto',
70
+ mensaje: 'El formato de archivo no permitido. Los formatos permitidos son: ' + this.FormatosPermitidos.join(', '),
71
+ textoAceptar: 'Continuar',
72
+ onClose: () => { },
73
+ onAccept: () => { },
74
+ },
75
+ });
65
76
  }
66
77
  }
67
78
  }
@@ -102,7 +113,7 @@ export class SubirArchivoComponent implements OnInit {
102
113
  }
103
114
 
104
115
  CargarArchivo(archivo: any, Etiqueta: string) {
105
- this.http.post(this.datosGlobalesService.ObtenerURL() + 'misc/cargarArchivo/' + Etiqueta,
116
+ this.http.post(this.datosGlobalesService.ObtenerURL() + this.RutaParaCargar + Etiqueta,
106
117
  archivo)
107
118
  .subscribe({
108
119
  next: (data: any) => {