Last active
May 28, 2018 14:24
-
-
Save nhh/d2abcdcf59b32c2b337c080e26f8b472 to your computer and use it in GitHub Desktop.
IsAuthenticatedGuard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanActivateChild} from '@angular/router'; | |
import { Router} from "@angular/router"; | |
import { Observable } from 'rxjs'; | |
import { AuthService } from '../service/auth/auth.service'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class IsAuthenticatedGuard implements CanActivate { | |
constructor( | |
private authService: AuthService | |
) {}; | |
canActivate( | |
next: ActivatedRouteSnapshot, | |
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { | |
return this.authService.isAuthenticated(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment