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