mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
fix: Don't permit duplicate groups in occ admin-delegation:add
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
This commit is contained in:
parent
9cd2e5bed9
commit
39291ca393
1 changed files with 10 additions and 2 deletions
|
|
@ -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.'.');
|
||||
|
|
|
|||
Loading…
Reference in a new issue