mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
Improve local storage
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LocalstoreService } from '../store/localstore.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuard implements CanActivate {
|
||||
constructor(
|
||||
private router:Router
|
||||
private router:Router,
|
||||
private localstoreService: LocalstoreService
|
||||
){}
|
||||
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
|
||||
if(window.location.pathname != '' && !localStorage.getItem('UserData')) {
|
||||
if(window.location.pathname != '' && !this.localstoreService.get('UserData', false)) {
|
||||
this.router.navigate(['/']);
|
||||
return false
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user