Skip to content
Snippets Groups Projects
Commit e5e77b37 authored by Christopher Schäpers's avatar Christopher Schäpers
Browse files

Make ResetAdminPass to ResetPassword

parent 011bd0a1
No related branches found
No related tags found
No related merge requests found
...@@ -13,24 +13,40 @@ use Symfony\Component\Console\Input\InputInterface; ...@@ -13,24 +13,40 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class ResetAdminPass extends Command { class ResetPassword extends Command {
protected function configure() { protected function configure() {
$this $this
->setName('resetadminpass') ->setName('resetpassword')
->setDescription('Resets the password of the first user') ->setDescription('Resets the password of the named user')
->addArgument( ->addArgument(
'password', 'user',
InputArgument::REQUIRED, InputArgument::REQUIRED,
'Password to reset to' 'Username to reset password'
); );
; ;
} }
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$password = $input->getArgument('password'); $username = $input->getArgument('user');
$query = \OC_DB::prepare('SELECT `uid` FROM `*PREFIX*users` LIMIT 1'); if ($input->isInteractive()) {
$username = $query->execute()->fetchOne(); $dialog = $this->getHelperSet()->get('dialog');
\OC_User::setPassword($username, $password); $password = $dialog->askHiddenResponse(
$output->writeln("Successfully reset password for " . $username . " to " . $password); $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!");
}
} }
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
$application->add(new OC\Core\Command\Status); $application->add(new OC\Core\Command\Status);
$application->add(new OC\Core\Command\Db\GenerateChangeScript()); $application->add(new OC\Core\Command\Db\GenerateChangeScript());
$application->add(new OC\Core\Command\Upgrade()); $application->add(new OC\Core\Command\Upgrade());
$application->add(new OC\Core\Command\ResetAdminPass()); $application->add(new OC\Core\Command\ResetPassword());
$application->add(new OC\Core\Command\Maintenance\SingleUser()); $application->add(new OC\Core\Command\Maintenance\SingleUser());
$application->add(new OC\Core\Command\App\Disable()); $application->add(new OC\Core\Command\App\Disable());
$application->add(new OC\Core\Command\App\Enable()); $application->add(new OC\Core\Command\App\Enable());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment