Answer the question
In order to leave comments, you need to log in
How to display the error No permissions?
i have this router
{
path: 'login',
component: LoginLayoutComponent,
},
{
path: 'dashboard',
component: MainLayoutComponent,
canActivate: [AuthGuard],
data: { role: 'admin' },
},
canActivate(route: ActivatedRouteSnapshot) {
let user : User = this.userService.getCurrentUser();
let role = route.data['role'];
//console.log(route.url[0].path);
if(user.role == role) {
return true;
} else {
if(permissionDependence[user.role][role]) {
return true;
} else {
//this.router.navigate(['/permission/'])
}
}
// not logged in so redirect to login page
this.router.navigate(['/login']);
return false;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question