This commit is contained in:
@@ -22,12 +22,7 @@ export const accountViewerGuard: CanActivateFn = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const mayViewAccounts =
|
||||
credentialService.isEffectiveSuperAdmin() ||
|
||||
credentialService.isEffectiveAdmin() ||
|
||||
credentialService.isEffectiveManager();
|
||||
|
||||
if (!mayViewAccounts) {
|
||||
if (!credentialService.canReadAccounts()) {
|
||||
void router.navigate(['/dashboard']);
|
||||
resolve(false);
|
||||
return;
|
||||
@@ -38,4 +33,4 @@ export const accountViewerGuard: CanActivateFn = () => {
|
||||
{ injector },
|
||||
);
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -44,15 +44,8 @@
|
||||
@for (itemGroup of navItemGroups; track $index) {
|
||||
<div>
|
||||
@if (
|
||||
(!itemGroup.adminOnly ||
|
||||
credentialService.isEffectiveSuperAdmin() ||
|
||||
credentialService.isEffectiveAdmin()) &&
|
||||
(!itemGroup.superAdminOnly ||
|
||||
credentialService.isEffectiveSuperAdmin()) &&
|
||||
(!itemGroup.managerOrAdminOnly ||
|
||||
credentialService.isEffectiveSuperAdmin() ||
|
||||
credentialService.isEffectiveAdmin() ||
|
||||
credentialService.isEffectiveManager())
|
||||
!itemGroup.requiredPermission ||
|
||||
credentialService.permissions().includes(itemGroup.requiredPermission)
|
||||
) {
|
||||
<mat-divider></mat-divider>
|
||||
@if (!collapsed()) {
|
||||
@@ -149,4 +142,4 @@
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</aside>
|
||||
</aside>
|
||||
@@ -17,17 +17,13 @@ type NavItem = {
|
||||
route: string;
|
||||
disabled: boolean;
|
||||
queryParams?: Record<string, string | number | boolean>;
|
||||
adminOnly?: boolean;
|
||||
superAdminOnly?: boolean;
|
||||
managerOrAdminOnly?: boolean;
|
||||
requiredPermission?: string;
|
||||
};
|
||||
|
||||
type NavItemGroup = {
|
||||
label: string;
|
||||
items: NavItem[];
|
||||
adminOnly?: boolean;
|
||||
superAdminOnly?: boolean;
|
||||
managerOrAdminOnly?: boolean;
|
||||
requiredPermission?: string;
|
||||
};
|
||||
|
||||
@Component({
|
||||
@@ -127,36 +123,35 @@ export class AppMenuComponent {
|
||||
icon: 'manage_accounts',
|
||||
route: '/accounts',
|
||||
disabled: false,
|
||||
managerOrAdminOnly: true,
|
||||
requiredPermission: 'READ_ACCOUNTS',
|
||||
},
|
||||
{
|
||||
label: 'Organisationen',
|
||||
icon: 'domain',
|
||||
route: '/organizations',
|
||||
disabled: false,
|
||||
superAdminOnly: true,
|
||||
requiredPermission: 'MANAGE_ORGANIZATIONS',
|
||||
},
|
||||
];
|
||||
|
||||
navItemGroups: NavItemGroup[] = [
|
||||
{
|
||||
label: 'Navigation',
|
||||
items: this.navItems.filter(
|
||||
(item) =>
|
||||
!item.adminOnly && !item.superAdminOnly && !item.managerOrAdminOnly,
|
||||
),
|
||||
items: this.navItems.filter((item) => !item.requiredPermission),
|
||||
},
|
||||
{
|
||||
label: 'Administration',
|
||||
items: this.navItems.filter(
|
||||
(item) =>
|
||||
(item.adminOnly || item.managerOrAdminOnly) && !item.superAdminOnly,
|
||||
(item) => item.requiredPermission === 'READ_ACCOUNTS',
|
||||
),
|
||||
managerOrAdminOnly: true,
|
||||
requiredPermission: 'READ_ACCOUNTS',
|
||||
},
|
||||
{
|
||||
label: 'Super Administration',
|
||||
items: this.navItems.filter((item) => item.superAdminOnly),
|
||||
superAdminOnly: true,
|
||||
items: this.navItems.filter(
|
||||
(item) => item.requiredPermission === 'MANAGE_ORGANIZATIONS',
|
||||
),
|
||||
requiredPermission: 'MANAGE_ORGANIZATIONS',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -182,4 +177,4 @@ export class AppMenuComponent {
|
||||
void this.credentialService.logoutAccount();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user