Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created July 25, 2020 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssukhpinder/d786d8e0639864ce822a0017a3097c5c to your computer and use it in GitHub Desktop.
Save ssukhpinder/d786d8e0639864ce822a0017a3097c5c to your computer and use it in GitHub Desktop.
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