X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fadmin-guard.service.ts;h=429dc032db78c9bf2febe5cdcd2b75fc3158af64;hb=f47bf2e142b0b22460558e23720f5aed8deb982c;hp=a0ad4817562bdbfa9e6d5f1be5964576eb8a593e;hpb=35bf0c83c80f59ca79f4b84fac8700f17adeb22d;p=github%2FChocobozzz%2FPeerTube.git 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 { ActivatedRouteSnapshot, CanActivateChild, RouterStateSnapshot, - CanActivate + CanActivate, + Router } from '@angular/router' import { AuthService } from '../core' @@ -11,10 +12,16 @@ import { AuthService } from '../core' @Injectable() export class AdminGuard implements CanActivate, CanActivateChild { - constructor (private auth: AuthService) {} + constructor ( + private router: Router, + private auth: AuthService + ) {} canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { - return this.auth.isAdmin() + if (this.auth.isAdmin() === true) return true + + this.router.navigate([ '/login' ]) + return false } canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {