1 import { Injectable } from '@angular/core'
3 ActivatedRouteSnapshot,
8 } from '@angular/router'
10 import { AuthService } from '../auth/auth.service'
13 export class LoginGuard implements CanActivate, CanActivateChild {
16 private router: Router,
17 private auth: AuthService
20 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
21 if (this.auth.isLoggedIn() === true) return true
23 this.router.navigate([ '/login' ])
27 canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
28 return this.canActivate(route, state)