Created
July 25, 2020 11:31
-
-
Save ssukhpinder/d786d8e0639864ce822a0017a3097c5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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, UrlTree } from '@angular/router'; | |
import { Observable } from 'rxjs'; | |
import { AuthGuardService } from './auth-guard.service'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthenticationGuard implements CanActivate { | |
constructor(private authService: AuthGuardService) { } | |
canActivate( | |
next: ActivatedRouteSnapshot, | |
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree { | |
return this.authService.getToken(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment