Fixed getting all permissions for users

ref #79
This commit is contained in:
2021-01-08 20:17:05 +01:00
parent 3bd4948c43
commit aa0337ea33
3 changed files with 12 additions and 9 deletions

View File

@@ -132,18 +132,20 @@ export class User extends Principal {
* Resolves all permissions granted to this user through groups or directly to the string enum format.
*/
public get allPermissions(): string[] {
let allPermissions = new Array<string>();
for (let permission in this.permissions) {
allPermissions.push(permission.toString());
let returnPermissions: string[] = new Array<string>();
if (!this.permissions) { return returnPermissions; }
for (let permission of this.permissions) {
returnPermissions.push(permission.toString());
}
if (!this.groups) { return returnPermissions; }
for (let group of this.groups) {
for (let permission in group.permissions) {
allPermissions.push(permission.toString());
for (let permission of group.permissions) {
returnPermissions.push(permission.toString());
}
}
console.log(allPermissions)
return Array.from(new Set(allPermissions));
return Array.from(new Set(returnPermissions));
}
/**