]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/core/routing/unlogged-guard.service.ts
Merge remote-tracking branch 'weblate/develop' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / core / routing / unlogged-guard.service.ts
1 import { Injectable } from '@angular/core'
2 import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, 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 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 }