aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-10 10:18:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-10 10:24:02 +0200
commitf47bf2e142b0b22460558e23720f5aed8deb982c (patch)
tree63a084494585a67e4326bf18c611e108de59aaee /client/src/app/+admin
parent35bf0c83c80f59ca79f4b84fac8700f17adeb22d (diff)
downloadPeerTube-f47bf2e142b0b22460558e23720f5aed8deb982c.tar.gz
PeerTube-f47bf2e142b0b22460558e23720f5aed8deb982c.tar.zst
PeerTube-f47bf2e142b0b22460558e23720f5aed8deb982c.zip
Client: check user is logged in for some pages
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/admin-guard.service.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/client/src/app/+admin/admin-guard.service.ts b/client/src/app/+admin/admin-guard.service.ts
index a0ad48175..429dc032d 100644
--- a/client/src/app/+admin/admin-guard.service.ts
+++ b/client/src/app/+admin/admin-guard.service.ts
@@ -3,7 +3,8 @@ import {
3 ActivatedRouteSnapshot, 3 ActivatedRouteSnapshot,
4 CanActivateChild, 4 CanActivateChild,
5 RouterStateSnapshot, 5 RouterStateSnapshot,
6 CanActivate 6 CanActivate,
7 Router
7} from '@angular/router' 8} from '@angular/router'
8 9
9import { AuthService } from '../core' 10import { AuthService } from '../core'
@@ -11,10 +12,16 @@ import { AuthService } from '../core'
11@Injectable() 12@Injectable()
12export class AdminGuard implements CanActivate, CanActivateChild { 13export class AdminGuard implements CanActivate, CanActivateChild {
13 14
14 constructor (private auth: AuthService) {} 15 constructor (
16 private router: Router,
17 private auth: AuthService
18 ) {}
15 19
16 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { 20 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
17 return this.auth.isAdmin() 21 if (this.auth.isAdmin() === true) return true
22
23 this.router.navigate([ '/login' ])
24 return false
18 } 25 }
19 26
20 canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { 27 canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {