|
|
@@ -10,6 +10,7 @@ import { ActividadService } from '../../../Administrador/services/actividad.serv
|
|
|
import { ActividadUser } from '../../../Administrador/interfaces/ActividadUser.interface';
|
|
|
import { format } from 'date-fns';
|
|
|
import Swal from 'sweetalert2';
|
|
|
+import { NavbarHomeComponent } from '../../../../shared/navbar-home/navbar-home.component';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-layout-page',
|
|
|
@@ -57,6 +58,7 @@ export class LayoutPageComponent {
|
|
|
private _enviarInfo: EnviarInfoService,
|
|
|
private authService: AuthService,
|
|
|
private actividadService: ActividadService,
|
|
|
+ private navbarHome: NavbarHomeComponent
|
|
|
// private navbarHome: NavbarHomeComponent
|
|
|
) {
|
|
|
|
|
|
@@ -189,6 +191,25 @@ export class LayoutPageComponent {
|
|
|
this._enviarInfo.changeColorLinks(this.links);
|
|
|
})
|
|
|
|
|
|
+ const expira = localStorage.getItem('expira');
|
|
|
+ if (expira) {
|
|
|
+ const expiraDate = new Date(parseInt(expira, 10));
|
|
|
+ const now = new Date();
|
|
|
+
|
|
|
+ if (now > expiraDate) {
|
|
|
+
|
|
|
+ console.log('La fecha de expiración ha pasado.');
|
|
|
+ Swal.fire({
|
|
|
+ icon: 'info',
|
|
|
+ title: 'Ha estado inactivo por mucho tiempo, por favor inicie sesión nuevamente.'
|
|
|
+ })
|
|
|
+ // this.navbarHome.actualizarActividad();
|
|
|
+ this.navbarHome.logout();
|
|
|
+ } else {
|
|
|
+ console.log('La fecha de expiración no ha pasado.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// const actual = new Date();
|
|
|
// console.log(actual.toLocaleTimeString());
|
|
|
|
|
|
@@ -212,14 +233,8 @@ export class LayoutPageComponent {
|
|
|
confirmButtonColor: 'rgb(237,46,56)',
|
|
|
confirmButtonText: 'Ok'
|
|
|
}).then(() => {
|
|
|
- this._authService.logout().subscribe(() => {
|
|
|
localStorage.clear();
|
|
|
this._router.navigate(['']); // ruta login explícita
|
|
|
- }, () => {
|
|
|
- // Incluso si falla el logout del backend, borra y navega
|
|
|
- localStorage.clear();
|
|
|
- this._router.navigate(['']);
|
|
|
- });
|
|
|
});
|
|
|
});
|
|
|
|