Renamed groups to roles in the frontend
Working: Account Cost Centre Employee Product Group Product Role User Client
This commit is contained in:
@ -15,13 +15,14 @@ export class AuthGuard implements CanActivate {
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
const user = this.authService.user;
|
||||
const permission = route.data['permission'].replace(/ /g, '-').toLowerCase();
|
||||
const permission = (route.data['permission'] === undefined) ? route.data['permission'] : route.data['permission']
|
||||
.replace(/ /g, '-')
|
||||
.toLowerCase();
|
||||
if (!user) {
|
||||
// not logged in so redirect to login page with the return url
|
||||
this.router.navigate(['/login'], {queryParams: {returnUrl: state.url}});
|
||||
return false;
|
||||
}
|
||||
console.log(permission, user.perms.indexOf(permission));
|
||||
if (permission !== undefined && user.perms.indexOf(permission) === -1) {
|
||||
this.toaster.show('Danger', 'You do not have the permission to access this area.');
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user