1 import { Injectable } from '@angular/core'
2 import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router'
3 import { AuthService } from '../auth/auth.service'
4 import { RedirectService } from './redirect.service'
7 export class UnloggedGuard implements CanActivate, CanActivateChild {
10 private router: Router,
11 private auth: AuthService,
12 private redirectService: RedirectService
15 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
16 if (this.auth.isLoggedIn() === false) return true
18 this.redirectService.redirectToHomepage()
22 canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
23 return this.canActivate(route, state)