From: Thomas Müller Date: Thu, 9 Apr 2015 22:08:40 +0000 (+0200) Subject: Merge pull request #15404 from Crote/occ-password-from-env X-Git-Tag: v8.1.0alpha1~41 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=13178db46503402cf9fe34235519e3335c788752;p=nextcloud-server.git Merge pull request #15404 from Crote/occ-password-from-env Add password input from env variable for occ user:{add, resetpassword} --- 13178db46503402cf9fe34235519e3335c788752 diff --cc core/command/user/add.php index 1ae0ffbe2ad,a566ed2db7a..60c70bf13dd --- a/core/command/user/add.php +++ b/core/command/user/add.php @@@ -81,17 -81,36 +81,36 @@@ class Add extends Command $uid = $input->getArgument('uid'); if ($this->userManager->userExists($uid)) { $output->writeln('The user "' . $uid . '" already exists.'); - return; + return 1; } - $password = $input->getOption('password'); - while (!$password) { - $question = new Question('Please enter a non-empty password:'); - $question->setHidden(true); - $question->setHiddenFallback(false); + if ($input->getOption('password-from-env')) { + $password = getenv('OC_PASS'); + if (!$password) { + $output->writeln('--password-from-env given, but OC_PASS is empty!'); + return 1; + } + } elseif ($input->isInteractive()) { + /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ + $dialog = $this->getHelperSet()->get('dialog'); + $password = $dialog->askHiddenResponse( + $output, + 'Enter password: ', + false + ); + $confirm = $dialog->askHiddenResponse( + $output, + 'Confirm password: ', + false + ); - $helper = $this->getHelper('question'); - $password = $helper->ask($input, $output, $question); + if ($password !== $confirm) { + $output->writeln("Passwords did not match!"); + return 1; + } + } else { + $output->writeln("Interactive input or --password-from-env is needed for entering a password!"); + return 1; } $user = $this->userManager->createUser(