@@ -1,12 +1,11 @@
|
||||
import {
|
||||
IsInt,
|
||||
IsNotEmpty,
|
||||
|
||||
IsString
|
||||
IsNotEmpty
|
||||
} from "class-validator";
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { User } from './User';
|
||||
import { UserGroup } from './UserGroup';
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { PermissionAction } from '../enums/PermissionAction';
|
||||
import { PermissionTarget } from '../enums/PermissionTargets';
|
||||
import { Principal } from './Principal';
|
||||
/**
|
||||
* Defines the Permission interface.
|
||||
*/
|
||||
@@ -20,30 +19,27 @@ export abstract class Permission {
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* users
|
||||
* The permissions principal
|
||||
*/
|
||||
@OneToMany(() => User, user => user.permissions, { nullable: true })
|
||||
users: User[]
|
||||
|
||||
/**
|
||||
* groups
|
||||
*/
|
||||
@OneToMany(() => UserGroup, group => group.permissions, { nullable: true })
|
||||
groups: UserGroup[]
|
||||
@ManyToOne(() => Principal, principal => principal.permissions)
|
||||
principal: Principal[]
|
||||
|
||||
/**
|
||||
* The target
|
||||
*/
|
||||
@Column()
|
||||
@Column({
|
||||
type: 'simple-enum',
|
||||
enum: PermissionTarget
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
target: string;
|
||||
target: PermissionTarget;
|
||||
|
||||
/**
|
||||
* The action type
|
||||
*/
|
||||
@Column()
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
action: string;
|
||||
@Column({
|
||||
type: 'simple-enum',
|
||||
enum: PermissionAction
|
||||
})
|
||||
action: PermissionAction;
|
||||
}
|
||||
Reference in New Issue
Block a user