mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 14:23:17 -04:00
feat(occ): allow admins to clear account passwords
Signed-off-by: Kent Delante <kent.delante@proton.me>
This commit is contained in:
parent
42c0e5ffeb
commit
711bd2bc6d
1 changed files with 29 additions and 13 deletions
|
|
@ -43,6 +43,12 @@ class ResetPassword extends Base {
|
|||
InputOption::VALUE_NONE,
|
||||
'read password from environment variable NC_PASS/OC_PASS'
|
||||
)
|
||||
->addOption(
|
||||
'no-password',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Sets the password to blank'
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
@ -76,22 +82,32 @@ class ResetPassword extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
$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>');
|
||||
|
|
|
|||
Loading…
Reference in a new issue