]>
Commit | Line | Data |
---|---|---|
b247a132 C |
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' | |
5 | ||
6 | @Injectable() | |
7 | export class UnloggedGuard implements CanActivate, CanActivateChild { | |
8 | ||
9 | constructor ( | |
10 | private router: Router, | |
11 | private auth: AuthService, | |
12 | private redirectService: RedirectService | |
13 | ) {} | |
14 | ||
15 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | |
16 | if (this.auth.isLoggedIn() === false) return true | |
17 | ||
18 | this.redirectService.redirectToHomepage() | |
19 | return false | |
20 | } | |
21 | ||
22 | canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | |
23 | return this.canActivate(route, state) | |
24 | } | |
25 | } |