Skip to content

Instantly share code, notes, and snippets.


gdyrrahitis/auth.guard.ts Secret

Created Aug 18, 2018
What would you like to do?
export class AuthGuard implements CanActivate {
constructor(private authService: AuthService, private router: Router) {
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
if(this.authService.isAuthenticated()) {
return true;
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } });
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment