| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { Injectable } from '@angular/core';
- import { MatSnackBar } from '@angular/material/snack-bar';
- import {
- ActivatedRouteSnapshot,
- CanActivate,
- RouterStateSnapshot,
- Router,
- UrlTree,
- } from '@angular/router';
- import { BehaviorSubject, firstValueFrom, lastValueFrom, Observable, Subscription } from 'rxjs';
- import { USERInterface } from '../interfaces/user-interface';
- import { ENCService } from '../services/enc/enc.service';
- import { IAMService } from '../services/iam/iam.service';
- import { LocalstorageService } from '../services/localstorage.service';
- import { MCOMAUService } from '../services/mco/mcomau/mcomau.service';
- import { WebSocketService } from '../services/socket/web-socket.service';
- import { ValidationsService } from '../services/validations.service';
- @Injectable({
- providedIn: 'root',
- })
- export class AuthGuard implements CanActivate {
- jwt: Observable<string[]> = {} as Observable<string[]>;
- private _docSub: Subscription = {} as Subscription;
- rfc_local: string = "";
- user_local: string = "";
- private empresas_arr: any[] = [];
-
- constructor(
- private router: Router,
- public setUserStorage: LocalstorageService
- ) { }
- canActivate(
- route: ActivatedRouteSnapshot,
- state: RouterStateSnapshot
- ) {
-
- let bloq = false;
-
- //Se checa si existe una sesión y si no hubo cambios
- let isLoggedIn = localStorage.getItem('jwt') != null;
- if (isLoggedIn && !bloq) {
- return true;
- }
- return this.router.navigate(['/iam']);
- }
- }
|