]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/core/routing/unlogged-guard.service.ts
9920ee41ddece5cfa8b606bd929de496946a25aa
[github/Chocobozzz/PeerTube.git] / client / src / app / core / routing / unlogged-guard.service.ts
1 import { Injectable } from '@angular/core'
2 import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'
3 import { AuthService } from '../auth/auth.service'
4 import { RedirectService } from './redirect.service'
5
6 @Injectable()
7 export class UnloggedGuard {
8
9 constructor (
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 }