mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
26 lines
697 B
TypeScript
26 lines
697 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
|
|
import { Observable } from 'rxjs';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class LoginGuard implements CanActivate {
|
|
constructor( private router:Router) {
|
|
|
|
}
|
|
canActivate(
|
|
route: ActivatedRouteSnapshot,
|
|
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
|
|
|
if(window.location.pathname == '/' && localStorage.getItem('UserData') != null ) {
|
|
this.router.navigate(['/home/events']);
|
|
return false
|
|
} else {
|
|
|
|
return true
|
|
}
|
|
}
|
|
|
|
}
|