]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/core/routing/login-guard.service.ts
Merge remote-tracking branch 'weblate/develop' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / core / routing / login-guard.service.ts
CommitLineData
f47bf2e1 1import { Injectable } from '@angular/core'
52798aa5 2import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'
954605a8 3import { AuthService } from '../auth/auth.service'
98bd5e22 4import { RedirectService } from './redirect.service'
f47bf2e1
C
5
6@Injectable()
52798aa5 7export class LoginGuard {
f47bf2e1
C
8
9 constructor (
98bd5e22
C
10 private auth: AuthService,
11 private redirectService: RedirectService
f47bf2e1
C
12 ) {}
13
14 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
15 if (this.auth.isLoggedIn() === true) return true
16
98bd5e22 17 this.redirectService.redirectToLogin()
f47bf2e1
C
18 return false
19 }
20
21 canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
22 return this.canActivate(route, state)
23 }
24}