{ "version": 3, "sources": ["src/app/core/guards/auth.guard.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\r\nimport { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router';\r\nimport { AuthService } from '../services/auth/auth.service';\r\nimport { Observable } from 'rxjs/internal/Observable';\r\n\r\n@Injectable({\r\n providedIn: 'root',\r\n})\r\nexport class AuthGuard {\r\n constructor(public authService: AuthService, public router: Router) { }\r\n\r\n canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean {\r\n return this.authService.isAuthenticatedAsync().then((validUser) => {\r\n if (validUser) {\r\n return true;\r\n } else {\r\n localStorage.clear();\r\n if (state.url && state.url === '/taxes') {\r\n this.router.navigate(['login'], { queryParams: { returnUrl: state.url }});\r\n } else {\r\n this.router.navigate(['login']);\r\n }\r\n return false;\r\n }\r\n }).catch(() => {\r\n localStorage.clear();\r\n this.router.navigate(['login']);\r\n return false;\r\n });\r\n }\r\n}\r\n"], "mappings": ";;;;;;;;AAQO,IAAM,YAAN,MAAMA,WAAS;EACpB,YAAmB,aAAiC,QAAc;AAA/C,SAAA,cAAA;AAAiC,SAAA,SAAA;EAAkB;EAEtE,YAAY,MAA8B,OAA0B;AAClE,WAAO,KAAK,YAAY,qBAAoB,EAAG,KAAK,CAAC,cAAa;AAChE,UAAI,WAAW;AACb,eAAO;MACT,OAAO;AACL,qBAAa,MAAK;AAClB,YAAI,MAAM,OAAO,MAAM,QAAQ,UAAU;AACvC,eAAK,OAAO,SAAS,CAAC,OAAO,GAAG,EAAE,aAAa,EAAE,WAAW,MAAM,IAAG,EAAE,CAAC;QAC1E,OAAO;AACL,eAAK,OAAO,SAAS,CAAC,OAAO,CAAC;QAChC;AACA,eAAO;MACT;IACF,CAAC,EAAE,MAAM,MAAK;AACZ,mBAAa,MAAK;AAClB,WAAK,OAAO,SAAS,CAAC,OAAO,CAAC;AAC9B,aAAO;IACT,CAAC;EACH;;;;;;;;AArBW,YAAS,WAAA;EAHrB,WAAW;IACV,YAAY;GACb;GACY,SAAS;", "names": ["AuthGuard"] }