This commit is contained in:
2025-11-21 15:48:38 +03:30
parent f07837cfdb
commit 89593d0f2e
5 changed files with 40 additions and 12 deletions
@@ -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));
}