Open sebrhex opened 4 months ago
Please see if the following patch addresses it for you:
diff --git a/apps/settings/lib/Command/AdminDelegation/Add.php b/apps/settings/lib/Command/AdminDelegation/Add.php
index 4ec6510f205..73c995b4762 100644
--- a/apps/settings/lib/Command/AdminDelegation/Add.php
+++ b/apps/settings/lib/Command/AdminDelegation/Add.php
@@ -40,16 +40,24 @@ class Add extends Base {
$io = new SymfonyStyle($input, $output);
$settingClass = $input->getArgument('settingClass');
if (!in_array(IDelegatedSettings::class, (array) class_implements($settingClass), true)) {
- $io->error('The specified class isn’t a valid delegated setting.');
+ $io->error('The specified class is not a valid delegated setting.');
return 2;
}
$groupId = $input->getArgument('groupId');
if (!$this->groupManager->groupExists($groupId)) {
- $io->error('The specified group didn’t exist.');
+ $io->error('The specified group does not exist.');
return 3;
}
+ $groups = $this->authorizedGroupService->findExistingGroupsForClass($settingClass);
+ foreach ($groups as $group) {
+ if ($group->getGroupId() === $groupId) {
+ $io->error('The specified group has already been delegated to.');
+ return 4;
+ }
+ }
+
$this->authorizedGroupService->create($groupId, $settingClass);
$io->success('Administration of '.$settingClass.' delegated to '.$groupId.'.');
Thank you very much for the fast reply, I can confirm this works for me! :smile:
⚠️ This issue respects the following points: ⚠️
Bug description
When I use e.g.
occ admin-delegation:add 'OCA\LogReader\Settings\Admin' logreaders
I can invoke this several times and subsequently have several identical entries of the same group for the delegation:There should be a check to prevent this as this is at least clogging up the view.
Steps to reproduce
occ admin-delegation:add
occ admin-delegation:add
occ admin-delegation:show
Expected behavior
An existing delegation should not be added.
Installation method
Community Docker image
Nextcloud Server version
29
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.2
Web server
Apache (supported)
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install?
Fresh Nextcloud Server install
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
No response
Additional info
No response