diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-10-10 10:18:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-10-10 10:24:02 +0200 |
commit | f47bf2e142b0b22460558e23720f5aed8deb982c (patch) | |
tree | 63a084494585a67e4326bf18c611e108de59aaee /client/src/app/+admin | |
parent | 35bf0c83c80f59ca79f4b84fac8700f17adeb22d (diff) | |
download | PeerTube-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.ts | 13 |
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 | ||
9 | import { AuthService } from '../core' | 10 | import { AuthService } from '../core' |
@@ -11,10 +12,16 @@ import { AuthService } from '../core' | |||
11 | @Injectable() | 12 | @Injectable() |
12 | export class AdminGuard implements CanActivate, CanActivateChild { | 13 | export 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) { |