1@Injectable({
2 providedIn: 'root'
3})
4export class AuthGuard implements CanActivate {
5 constructor(private authService: AuthService, private router: Router) {}
6
7 canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
8 if (!this.authService.isLoggedIn) {
9 return this.router.parseUrl('/notauthorized');
10 } else {
11 return true;
12 }
13 }
14}
15