up
This commit is contained in:
@@ -49,6 +49,11 @@ 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 to roles');
|
||||
}
|
||||
permissions.forEach(p => role.permissions.add(p));
|
||||
}
|
||||
|
||||
@@ -122,6 +127,11 @@ 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