summaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2019-11-25 17:16:40 +0100
committerGitHub <noreply@github.com>2019-11-25 17:16:40 +0100
commitb1dffc5c2dd17216c87788bf36b8e15b45be2241 (patch)
tree164de89542956784da0c7046c5fb00c09aa423ea /core/Command
parent279c0cb2ed99c3914f19468c267344aa3a2f04e6 (diff)
parentb4408e4245ca4045df7a5f8fdf6ba9100730fa4f (diff)
downloadnextcloud-server-b1dffc5c2dd17216c87788bf36b8e15b45be2241.tar.gz
nextcloud-server-b1dffc5c2dd17216c87788bf36b8e15b45be2241.zip
Merge pull request #17896 from nextcloud/fix/noid/consider-create-group-result
take group creation result into consideration
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Group/Add.php8
-rw-r--r--core/Command/User/Add.php11
2 files changed, 15 insertions, 4 deletions
diff --git a/core/Command/Group/Add.php b/core/Command/Group/Add.php
index f2ee6195a44..4850ec9ce6c 100644
--- a/core/Command/Group/Add.php
+++ b/core/Command/Group/Add.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace OC\Core\Command\Group;
use OC\Core\Command\Base;
+use OCP\IGroup;
use OCP\IGroupManager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -68,12 +69,17 @@ class Add extends Base {
return 1;
} else {
$group = $this->groupManager->createGroup($gid);
+ if (!$group instanceof IGroup) {
+ $output->writeln('<error>Could not create group</error>');
+ return 2;
+ }
$output->writeln('Created group "' . $group->getGID() . '"');
- $displayName = trim((string) $input->getOption('display-name'));
+ $displayName = trim((string)$input->getOption('display-name'));
if ($displayName !== '') {
$group->setDisplayName($displayName);
}
}
+ return 0;
}
}
diff --git a/core/Command/User/Add.php b/core/Command/User/Add.php
index 047881fc37f..4dbf55b3fb8 100644
--- a/core/Command/User/Add.php
+++ b/core/Command/User/Add.php
@@ -25,6 +25,7 @@
namespace OC\Core\Command\User;
use OC\Files\Filesystem;
+use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
@@ -152,10 +153,14 @@ class Add extends Command {
if (!$group) {
$this->groupManager->createGroup($groupName);
$group = $this->groupManager->get($groupName);
- $output->writeln('Created group "' . $group->getGID() . '"');
+ if($group instanceof IGroup) {
+ $output->writeln('Created group "' . $group->getGID() . '"');
+ }
+ }
+ if($group instanceof IGroup) {
+ $group->addUser($user);
+ $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
}
- $group->addUser($user);
- $output->writeln('User "' . $user->getUID() . '" added to group "' . $group->getGID() . '"');
}
}
}