Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions core/Command/User/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ protected function configure() {
InputOption::VALUE_NONE,
'read password from environment variable NC_PASS/OC_PASS'
)
->addOption(
'no-password',
null,
InputOption::VALUE_NONE,
'Sets the password to blank'
)
;
}

Expand Down Expand Up @@ -76,22 +82,32 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$question = new Question('Enter a new password: ');
$question->setHidden(true);
$password = $helper->ask($input, $output, $question);
if ($input->getOption('no-password')) {
$question = new ConfirmationQuestion('Are you sure you want to clear the password for ' . $username . '?');

if ($password === null) {
$output->writeln('<error>Password cannot be empty!</error>');
return 1;
}
if (!$helper->ask($input, $output, $question)) {
return 1;
}

$question = new Question('Confirm the new password: ');
$question->setHidden(true);
$confirm = $helper->ask($input, $output, $question);
$password = '';
} else {
$question = new Question('Enter a new password: ');
$question->setHidden(true);
$password = $helper->ask($input, $output, $question);

if ($password !== $confirm) {
$output->writeln('<error>Passwords did not match!</error>');
return 1;
if ($password === null) {
$output->writeln('<error>Password cannot be empty!</error>');
return 1;
}

$question = new Question('Confirm the new password: ');
$question->setHidden(true);
$confirm = $helper->ask($input, $output, $question);

if ($password !== $confirm) {
$output->writeln('<error>Passwords did not match!</error>');
return 1;
}
}
} else {
$output->writeln('<error>Interactive input or --password-from-env is needed for entering a new password!</error>');
Expand Down
Loading