1 import { Injectable } from '@angular/core';
3 ActivatedRouteSnapshot,
8 } from '@angular/router';
10 import { AuthStorageService } from './auth-storage.service';
15 export class AuthGuardService implements CanActivate, CanActivateChild {
16 constructor(private router: Router, private authStorageService: AuthStorageService) {}
18 canActivate(_route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
19 if (this.authStorageService.isLoggedIn()) {
22 this.router.navigate(['/login'], { queryParams: { returnUrl: state.url } });
26 canActivateChild(childRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
27 return this.canActivate(childRoute, state);