Add permission and role management features

This commit is contained in:
faris Aljohari
2024-12-16 00:19:14 -06:00
parent 57397e653a
commit 64027d3a16
22 changed files with 473 additions and 17 deletions
@@ -3,6 +3,7 @@ import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { ProjectDto } from '../dtos';
import { CommunityEntity } from '../../community/entities';
import { SpaceModelEntity } from '../../space-model';
import { UserEntity } from '../../user/entities';
@Entity({ name: 'project' })
@Unique(['name'])
@@ -28,6 +29,9 @@ export class ProjectEntity extends AbstractEntity<ProjectDto> {
@OneToMany(() => CommunityEntity, (community) => community.project)
communities: CommunityEntity[];
@OneToMany(() => UserEntity, (user) => user.project)
public users: UserEntity[];
constructor(partial: Partial<ProjectEntity>) {
super();
Object.assign(this, partial);
@@ -2,7 +2,8 @@ import { Column, Entity, OneToMany, Unique } from 'typeorm';
import { AbstractEntity } from '../../abstract/entities/abstract.entity';
import { RoleTypeDto } from '../dtos/role.type.dto';
import { RoleType } from '@app/common/constants/role.type.enum';
import { UserRoleEntity } from '../../user/entities';
import { UserEntity } from '../../user/entities';
import { InviteUserEntity } from '../../Invite-user/entities';
@Entity({ name: 'role-type' })
@Unique(['type'])
@@ -12,10 +13,14 @@ export class RoleTypeEntity extends AbstractEntity<RoleTypeDto> {
enum: Object.values(RoleType),
})
type: string;
@OneToMany(() => UserRoleEntity, (role) => role.roleType, {
@OneToMany(() => UserEntity, (inviteUser) => inviteUser.roleType, {
nullable: true,
})
roles: UserRoleEntity[];
users: UserEntity[];
@OneToMany(() => InviteUserEntity, (inviteUser) => inviteUser.roleType, {
nullable: true,
})
invitedUsers: InviteUserEntity[];
constructor(partial: Partial<RoleTypeEntity>) {
super();
Object.assign(this, partial);
@@ -4,7 +4,6 @@ import {
UserEntity,
UserNotificationEntity,
UserOtpEntity,
UserRoleEntity,
UserSpaceEntity,
} from './entities';
@@ -17,7 +16,6 @@ import {
UserEntity,
UserNotificationEntity,
UserOtpEntity,
UserRoleEntity,
UserSpaceEntity,
]),
],