parent
37fc167002
commit
cd7b15aadf
@ -3,6 +3,7 @@ import { ChildEntity, Column, JoinTable, ManyToMany, OneToMany } from "typeorm";
|
|||||||
import { config } from '../../config';
|
import { config } from '../../config';
|
||||||
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
|
import { ResponsePrincipal } from '../responses/ResponsePrincipal';
|
||||||
import { ResponseUser } from '../responses/ResponseUser';
|
import { ResponseUser } from '../responses/ResponseUser';
|
||||||
|
import { Permission } from './Permission';
|
||||||
import { Principal } from './Principal';
|
import { Principal } from './Principal';
|
||||||
import { UserAction } from './UserAction';
|
import { UserAction } from './UserAction';
|
||||||
import { UserGroup } from './UserGroup';
|
import { UserGroup } from './UserGroup';
|
||||||
@ -129,8 +130,24 @@ export class User extends Principal {
|
|||||||
@OneToMany(() => UserAction, action => action.user, { nullable: true })
|
@OneToMany(() => UserAction, action => action.user, { nullable: true })
|
||||||
actions: UserAction[]
|
actions: UserAction[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves all permissions granted to this user through groups.
|
||||||
|
*/
|
||||||
|
public get inheritedPermissions(): Permission[] {
|
||||||
|
let returnPermissions: Permission[] = new Array<Permission>();
|
||||||
|
|
||||||
|
if (!this.groups) { return returnPermissions; }
|
||||||
|
for (let group of this.groups) {
|
||||||
|
for (let permission of group.permissions) {
|
||||||
|
returnPermissions.push(permission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves all permissions granted to this user through groups or directly to the string enum format.
|
* Resolves all permissions granted to this user through groups or directly to the string enum format.
|
||||||
|
* Also deduplicates the array.
|
||||||
*/
|
*/
|
||||||
public get allPermissions(): string[] {
|
public get allPermissions(): string[] {
|
||||||
let returnPermissions: string[] = new Array<string>();
|
let returnPermissions: string[] = new Array<string>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user