Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

Commit b7a11d4

Browse files
author
the-djmaze
committed
Don't input password in command, ask in prompt #1552
1 parent 372e4bc commit b7a11d4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

integrations/nextcloud/snappymail/lib/Command/Settings.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,12 @@ protected function configure() {
3737
)
3838
->addArgument(
3939
'pass',
40-
InputArgument::REQUIRED,
40+
InputArgument::OPTIONAL,
4141
'The login passphrase'
4242
)
4343
;
4444
}
4545

46-
protected function checkInput(InputInterface $input) {
47-
}
48-
4946
protected function execute(InputInterface $input, OutputInterface $output): int {
5047
$uid = $input->getArgument('uid');
5148
if (!$this->userManager->userExists($uid)) {
@@ -57,6 +54,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5754
$this->config->setUserValue($uid, 'snappymail', 'snappymail-email', $sEmail);
5855

5956
$sPass = $input->getArgument('pass');
57+
if (empty($sPass)) {
58+
// Prompt on command line for value
59+
if (\is_callable('readline')) {
60+
$sPass = \readline("password: ");
61+
} else {
62+
echo "password: ";
63+
$sPass = \stream_get_line(STDIN, 1024, PHP_EOL);
64+
}
65+
}
6066
$sPass = ($sEmail && $sPass) ? SnappyMailHelper::encodePassword($sPass, \md5($sEmail)) : '';
6167
$this->config->setUserValue($uid, 'snappymail', 'passphrase', $sPass);
6268
return 0;

0 commit comments

Comments
 (0)