作者:hoanie
项目:aspnetboilerplate-sample
selectBestRoute(): string {
if (!this._sessionService.user) {
return '/account/login';
}
if (this._permissionChecker.isGranted('Pages.Users')) {
return '/app/admin/users';
}
return '/app/home';
}
作者:hoanie
项目:aspnetboilerplate-sample
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
if (!this._sessionService.user) {
this._router.navigate(['/account/login']);
return false;
}
if (!route.data || !route.data["permission"]) {
return true;
}
if (this._permissionChecker.isGranted(route.data["permission"])) {
return true;
}
this._router.navigate([this.selectBestRoute()]);
return false;
}