From b7a11d42de6d9df1ac2e784e73367a1ab454719e Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 23 Apr 2024 18:03:04 +0200 Subject: [PATCH] Don't input password in command, ask in prompt #1552 --- .../nextcloud/snappymail/lib/Command/Settings.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/integrations/nextcloud/snappymail/lib/Command/Settings.php b/integrations/nextcloud/snappymail/lib/Command/Settings.php index f1ccbf4f6..1e6cae25d 100644 --- a/integrations/nextcloud/snappymail/lib/Command/Settings.php +++ b/integrations/nextcloud/snappymail/lib/Command/Settings.php @@ -37,15 +37,12 @@ class Settings extends Base ) ->addArgument( 'pass', - InputArgument::REQUIRED, + InputArgument::OPTIONAL, 'The login passphrase' ) ; } - protected function checkInput(InputInterface $input) { - } - protected function execute(InputInterface $input, OutputInterface $output): int { $uid = $input->getArgument('uid'); if (!$this->userManager->userExists($uid)) { @@ -57,6 +54,15 @@ class Settings extends Base $this->config->setUserValue($uid, 'snappymail', 'snappymail-email', $sEmail); $sPass = $input->getArgument('pass'); + if (empty($sPass)) { + // Prompt on command line for value + if (\is_callable('readline')) { + $sPass = \readline("password: "); + } else { + echo "password: "; + $sPass = \stream_get_line(STDIN, 1024, PHP_EOL); + } + } $sPass = ($sEmail && $sPass) ? SnappyMailHelper::encodePassword($sPass, \md5($sEmail)) : ''; $this->config->setUserValue($uid, 'snappymail', 'passphrase', $sPass); return 0;