Convert resetpassword to question helper
This commit is contained in:
parent
a9c6c351cb
commit
25546b6c83
|
@ -29,10 +29,13 @@ namespace OC\Core\Command\User;
|
||||||
|
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||||
|
use Symfony\Component\Console\Question\Question;
|
||||||
|
|
||||||
class ResetPassword extends Command {
|
class ResetPassword extends Command {
|
||||||
|
|
||||||
|
@ -79,28 +82,27 @@ class ResetPassword extends Command {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} elseif ($input->isInteractive()) {
|
} elseif ($input->isInteractive()) {
|
||||||
/** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
|
/** @var QuestionHelper $helper */
|
||||||
$dialog = $this->getHelperSet()->get('dialog');
|
$helper = $this->getHelper('question');
|
||||||
|
|
||||||
if (\OCP\App::isEnabled('encryption')) {
|
if (\OCP\App::isEnabled('encryption')) {
|
||||||
$output->writeln(
|
$output->writeln(
|
||||||
'<error>Warning: Resetting the password when using encryption will result in data loss!</error>'
|
'<error>Warning: Resetting the password when using encryption will result in data loss!</error>'
|
||||||
);
|
);
|
||||||
if (!$dialog->askConfirmation($output, '<question>Do you want to continue?</question>', true)) {
|
|
||||||
|
$question = new ConfirmationQuestion('Do you want to continue?');
|
||||||
|
if (!$helper->ask($input, $output, $question)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$password = $dialog->askHiddenResponse(
|
$question = new Question('Enter a new password: ');
|
||||||
$output,
|
$question->setHidden(true);
|
||||||
'<question>Enter a new password: </question>',
|
$password = $helper->ask($input, $output, $question);
|
||||||
false
|
|
||||||
);
|
$question = new Question('Conform the new password: ');
|
||||||
$confirm = $dialog->askHiddenResponse(
|
$question->setHidden(true);
|
||||||
$output,
|
$confirm = $helper->ask($input, $output, $question);
|
||||||
'<question>Confirm the new password: </question>',
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($password !== $confirm) {
|
if ($password !== $confirm) {
|
||||||
$output->writeln("<error>Passwords did not match!</error>");
|
$output->writeln("<error>Passwords did not match!</error>");
|
||||||
|
|
Loading…
Reference in New Issue