Implemented permission getting

ref #6
This commit is contained in:
2020-12-18 15:12:06 +01:00
parent 388fc6ba6a
commit d89fcb84a2
5 changed files with 180 additions and 10 deletions

View File

@@ -0,0 +1,46 @@
import {
IsInt,
IsNotEmpty,
IsObject
} from "class-validator";
import { Permission } from '../entities/Permission';
import { Principal } from '../entities/Principal';
import { PermissionAction } from '../enums/PermissionAction';
import { PermissionTarget } from '../enums/PermissionTargets';
/**
* Defines a track of given length.
*/
export class ResponsePermission {
/**
* Autogenerated unique id (primary key).
*/
@IsInt()
id: number;;
/**
* The permissions's principal.
*/
@IsObject()
@IsNotEmpty()
principal: Principal;
/**
* The permissions's target.
*/
@IsNotEmpty()
target: PermissionTarget;
/**
* The permissions's action.
*/
@IsNotEmpty()
action: PermissionAction;
public constructor(permission: Permission) {
this.id = permission.id;
this.principal = permission.principal;
this.target = permission.target;
this.action = permission.action;
}
}