First part of the permission return (buggy!)

ref #79
This commit is contained in:
2021-01-08 19:32:04 +01:00
parent 3c37aafe1f
commit f3cd1380be
4 changed files with 22 additions and 22 deletions

View File

@@ -128,6 +128,24 @@ export class User extends Principal {
@OneToMany(() => UserAction, action => action.user, { nullable: true })
actions: UserAction[]
/**
* 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());
}
for (let group of this.groups) {
for (let permission in group.permissions) {
allPermissions.push(permission.toString());
}
}
console.log(allPermissions)
return Array.from(new Set(allPermissions));
}
/**
* Turns this entity into it's response class.
*/