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