diff options
author | kondou <kondou@ts.unde.re> | 2014-05-12 16:10:59 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2014-05-12 16:10:59 +0200 |
commit | e5e77b370a64c8e391d64a2924f49feee284eac2 (patch) | |
tree | f41c289b215e22d4798a8ea9c7bea42092cc89f7 /core/command | |
parent | 011bd0a1c47e32fb9df9fdd63524d24b04a7ae14 (diff) | |
download | nextcloud-server-e5e77b370a64c8e391d64a2924f49feee284eac2.tar.gz nextcloud-server-e5e77b370a64c8e391d64a2924f49feee284eac2.zip |
Make ResetAdminPass to ResetPassword
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/resetadminpass.php | 36 | ||||
-rw-r--r-- | core/command/resetpassword.php | 52 |
2 files changed, 52 insertions, 36 deletions
diff --git a/core/command/resetadminpass.php b/core/command/resetadminpass.php deleted file mode 100644 index 6f42801061b..00000000000 --- a/core/command/resetadminpass.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -/** - * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - -namespace OC\Core\Command; - -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; - -class ResetAdminPass extends Command { - protected function configure() { - $this - ->setName('resetadminpass') - ->setDescription('Resets the password of the first user') - ->addArgument( - 'password', - InputArgument::REQUIRED, - 'Password to reset to' - ); - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) { - $password = $input->getArgument('password'); - $query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` LIMIT 1'); - $username = $query->execute()->fetchOne(); - \OC_User::setPassword($username, $password); - $output->writeln("Successfully reset password for " . $username . " to " . $password); - } -} diff --git a/core/command/resetpassword.php b/core/command/resetpassword.php new file mode 100644 index 00000000000..fa91d0a73ac --- /dev/null +++ b/core/command/resetpassword.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace OC\Core\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Output\OutputInterface; + +class ResetPassword extends Command { + protected function configure() { + $this + ->setName('resetpassword') + ->setDescription('Resets the password of the named user') + ->addArgument( + 'user', + InputArgument::REQUIRED, + 'Username to reset password' + ); + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) { + $username = $input->getArgument('user'); + if ($input->isInteractive()) { + $dialog = $this->getHelperSet()->get('dialog'); + $password = $dialog->askHiddenResponse( + $output, + '<question>Enter a new password: </question>', + false + ); + $dialog = $this->getHelperSet()->get('dialog'); + $confirm = $dialog->askHiddenResponse( + $output, + '<question>Confirm the new password: </question>', + false + ); + } + if ($password === $confirm) { + \OC_User::setPassword($username, $password); + $output->writeln("Successfully reset password for " . $username); + } else { + $output->writeln("Passwords did not match!"); + } + } +} |