summaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
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() . '"');
}
}
}