[Pkg-owncloud-commits] [owncloud] 40/199: Use userManager, color output, return 1 on error
David Prévot
taffit at moszumanska.debian.org
Sun Jun 1 18:53:07 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit f216d814080f426cf092de06ddaf0ca42f4e8028
Author: kondou <kondou at ts.unde.re>
Date: Sat May 24 09:49:02 2014 +0200
Use userManager, color output, return 1 on error
---
core/command/resetpassword.php | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/core/command/resetpassword.php b/core/command/resetpassword.php
index 1580bdf..b518404 100644
--- a/core/command/resetpassword.php
+++ b/core/command/resetpassword.php
@@ -22,12 +22,20 @@ class ResetPassword extends Command {
'user',
InputArgument::REQUIRED,
'Username to reset password'
- );
+ )
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$username = $input->getArgument('user');
+
+ $userManager = \OC::$server->getUserManager();
+ $user = $userManager->get($username);
+ if (is_null($user)) {
+ $output->writeln("<error>There is no user called " . $username . "</error>");
+ return 1;
+ }
+
if ($input->isInteractive()) {
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
$dialog = $this->getHelperSet()->get('dialog');
@@ -36,8 +44,6 @@ class ResetPassword extends Command {
'<question>Enter a new password: </question>',
false
);
- /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
- $dialog = $this->getHelperSet()->get('dialog');
$confirm = $dialog->askHiddenResponse(
$output,
'<question>Confirm the new password: </question>',
@@ -45,17 +51,20 @@ class ResetPassword extends Command {
);
if ($password === $confirm) {
- $success = \OC_User::setPassword($username, $password);
+ $success = $user->setPassword($password);
if ($success) {
- $output->writeln("Successfully reset password for " . $username);
+ $output->writeln("<info>Successfully reset password for " . $username . "</info>");
} else {
- $output->writeln("There is no user called " . $username);
+ $output->writeln("<error>Error while resetting password!</error>");
+ return 1;
}
} else {
- $output->writeln("Passwords did not match!");
+ $output->writeln("<error>Passwords did not match!</error>");
+ return 1;
}
} else {
- $output->writeln("Interactive input is needed for entering a new password!");
+ $output->writeln("<error>Interactive input is needed for entering a new password!</error>");
+ return 1;
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list