summaryrefslogtreecommitdiffstats
path: root/core/command
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-04-23 12:32:46 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-04-23 12:32:46 +0200
commit07627084e4307e493f81c458350e8a563ac3a8fc (patch)
treedab995d4b2b81d96c1419c48fcbaa4cd917e75ed /core/command
parentf8f354b351a349898bbb5cdf2d9bee1c798c0f73 (diff)
downloadnextcloud-server-07627084e4307e493f81c458350e8a563ac3a8fc.tar.gz
nextcloud-server-07627084e4307e493f81c458350e8a563ac3a8fc.zip
Check if the user exists before trying to delete him
Diffstat (limited to 'core/command')
-rw-r--r--core/command/user/delete.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/core/command/user/delete.php b/core/command/user/delete.php
index 53952ceb9e1..2db80dae084 100644
--- a/core/command/user/delete.php
+++ b/core/command/user/delete.php
@@ -22,19 +22,20 @@
namespace OC\Core\Command\User;
+use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
class Delete extends Command {
- /** @var \OC\User\Manager */
+ /** @var IUserManager */
protected $userManager;
/**
- * @param \OC\User\Manager $userManager
+ * @param IUserManager $userManager
*/
- public function __construct(\OC\User\Manager $userManager) {
+ public function __construct(IUserManager $userManager) {
$this->userManager = $userManager;
parent::__construct();
}
@@ -51,11 +52,17 @@ class Delete extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output) {
- $wasSuccessful = $this->userManager->get($input->getArgument('uid'))->delete();
- if($wasSuccessful === true) {
+ $user = $this->userManager->get($input->getArgument('uid'));
+ if (is_null($user)) {
+ $output->writeln('User does not exist');
+ return;
+ }
+
+ if ($user->delete()) {
$output->writeln('The specified user was deleted');
return;
}
+
$output->writeln('<error>The specified could not be deleted. Please check the logs.</error>');
}
}