]>
Commit | Line | Data |
---|---|---|
b247a132 | 1 | import { Injectable } from '@angular/core' |
67ed6552 | 2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router' |
b247a132 C |
3 | import { AuthService } from '../auth/auth.service' |
4 | import { RedirectService } from './redirect.service' | |
5 | ||
6 | @Injectable() | |
7 | export class UnloggedGuard implements CanActivate, CanActivateChild { | |
8 | ||
9 | constructor ( | |
b247a132 C |
10 | private auth: AuthService, |
11 | private redirectService: RedirectService | |
12 | ) {} | |
13 | ||
14 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | |
15 | if (this.auth.isLoggedIn() === false) return true | |
16 | ||
17 | this.redirectService.redirectToHomepage() | |
18 | return false | |
19 | } | |
20 | ||
21 | canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | |
22 | return this.canActivate(route, state) | |
23 | } | |
24 | } |