permission object builder fix

This commit is contained in:
Julian Krauser 2024-09-15 13:53:10 +02:00
parent 723f05bfca
commit c543d4e4ed
2 changed files with 23 additions and 12 deletions

View file

@ -109,7 +109,12 @@ export default class PermissionHelper {
} }
const permissionIndex = permissionTypes.indexOf(split[1] as PermissionType); const permissionIndex = permissionTypes.indexOf(split[1] as PermissionType);
const appliedPermissions = permissionTypes.slice(0, permissionIndex + 1); const appliedPermissions = permissionTypes.slice(0, permissionIndex + 1);
output[split[0]].all = appliedPermissions;
if (output[split[0]].all != "*") {
output[split[0]].all = [
...new Set([...output[split[0]].all, ...appliedPermissions]),
] as Array<PermissionType>;
}
} else { } else {
if (split[2] == "*" || output[split[0]][split[1] as PermissionModule] == "*") { if (split[2] == "*" || output[split[0]][split[1] as PermissionModule] == "*") {
output[split[0]][split[1] as PermissionModule] = "*"; output[split[0]][split[1] as PermissionModule] = "*";
@ -123,6 +128,11 @@ export default class PermissionHelper {
const permissionIndex = permissionTypes.indexOf(split[2] as PermissionType); const permissionIndex = permissionTypes.indexOf(split[2] as PermissionType);
const appliedPermissions = permissionTypes.slice(0, permissionIndex + 1); const appliedPermissions = permissionTypes.slice(0, permissionIndex + 1);
output[split[0]][split[1] as PermissionModule] = appliedPermissions; output[split[0]][split[1] as PermissionModule] = appliedPermissions;
if (output[split[0]][split[1] as PermissionModule] != "*") {
output[split[0]][split[1] as PermissionModule] = [
...new Set([...output[split[0]][split[1] as PermissionModule], ...appliedPermissions]),
] as Array<PermissionType>;
}
} }
} }
} }
@ -145,8 +155,10 @@ export default class PermissionHelper {
output.push(`${section}.${type}`); output.push(`${section}.${type}`);
} }
} }
} else { }
let modules = Object.keys(permissions[section]) as Array<PermissionModule>; let modules = Object.keys(permissions[section]).filter((m: PermissionModule) =>
permissionModules.includes(m)
) as Array<PermissionModule>;
for (let module of modules) { for (let module of modules) {
let types = permissions[section][module]; let types = permissions[section][module];
if (types == "*" || types.length == permissionTypes.length) { if (types == "*" || types.length == permissionTypes.length) {
@ -158,7 +170,6 @@ export default class PermissionHelper {
} }
} }
} }
}
return output; return output;
} }

View file

@ -29,6 +29,6 @@ export default abstract class CommunicationService {
static getAvailableColumnsForCommunication(): Array<string> { static getAvailableColumnsForCommunication(): Array<string> {
let metadata = dataSource.getMetadata(communication); let metadata = dataSource.getMetadata(communication);
let columns = metadata.columns.map((c) => c.propertyName); let columns = metadata.columns.map((c) => c.propertyName);
return columns.filter((c) => !["id", "preffered", "type"].includes(c)); return columns.filter((c) => !["id", "preffered", "type", "member"].includes(c));
} }
} }