update roles and permissions
This commit is contained in:
@@ -10,9 +10,7 @@ export class Permission extends BaseEntity {
|
||||
|
||||
@Property()
|
||||
title!: string;
|
||||
// اضافه شد
|
||||
@Property({ default: 'general' })
|
||||
group!: string;
|
||||
|
||||
|
||||
@ManyToMany({ entity: () => Role, mappedBy: 'permissions' })
|
||||
roles = new Collection<Role>(this);
|
||||
|
||||
@@ -17,7 +17,7 @@ export class RolesService {
|
||||
@InjectRepository(Permission)
|
||||
private readonly permissionRepository: EntityRepository<Permission>,
|
||||
private readonly em: EntityManager,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async createRestaurantRole(dto: CreateRoleDto, restId: string) {
|
||||
const { name, permissionIds } = dto;
|
||||
@@ -48,11 +48,6 @@ export class RolesService {
|
||||
if (permissions.length !== permissionIds.length) {
|
||||
throw new BadRequestException('One or more permissions not found');
|
||||
}
|
||||
// Check if any permission is special
|
||||
const specialPermissions = permissions.filter(p => p.group === 'special');
|
||||
if (specialPermissions.length > 0) {
|
||||
throw new BadRequestException('Special permissions cannot be assigned');
|
||||
}
|
||||
permissions.forEach(p => role.permissions.add(p));
|
||||
}
|
||||
|
||||
@@ -102,11 +97,6 @@ export class RolesService {
|
||||
if (permissions.length !== dto.permissionIds.length) {
|
||||
throw new BadRequestException('One or more permissions not found');
|
||||
}
|
||||
// Check if any permission is special
|
||||
const specialPermissions = permissions.filter(p => p.group === 'special');
|
||||
if (specialPermissions.length > 0) {
|
||||
throw new BadRequestException('Special permissions cannot be assigned to roles');
|
||||
}
|
||||
permissions.forEach(p => role.permissions.add(p));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user