mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Resolve #1552
This commit is contained in:
parent
1b0962cce1
commit
027ce6ccae
2 changed files with 67 additions and 0 deletions
|
@ -86,4 +86,7 @@ There, click on the link to go to the SnappyMail admin panel.
|
|||
<step>OCA\SnappyMail\Migration\InstallStep</step>
|
||||
</post-migration>
|
||||
</repair-steps>
|
||||
<commands>
|
||||
<command>OCA\SnappyMail\Command\Settings</command>
|
||||
</commands>
|
||||
</info>
|
||||
|
|
64
integrations/nextcloud/snappymail/lib/Command/Settings.php
Normal file
64
integrations/nextcloud/snappymail/lib/Command/Settings.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\SnappyMail\Command;
|
||||
|
||||
use OCA\SnappyMail\Util\SnappyMailHelper;
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Settings extends Base
|
||||
{
|
||||
protected IUserManager $userManager;
|
||||
protected IConfig $config;
|
||||
|
||||
public function __construct(IUserManager $userManager, IConfig $config) {
|
||||
parent::__construct();
|
||||
$this->userManager = $userManager;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
$this
|
||||
->setName('snappymail:settings')
|
||||
->setDescription('modifies configuration')
|
||||
->addArgument(
|
||||
'uid',
|
||||
InputArgument::REQUIRED,
|
||||
'User ID used to login'
|
||||
)
|
||||
->addArgument(
|
||||
'user',
|
||||
InputArgument::REQUIRED,
|
||||
'The login username'
|
||||
)
|
||||
->addArgument(
|
||||
'pass',
|
||||
InputArgument::REQUIRED,
|
||||
'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)) {
|
||||
$output->writeln('<error>The user "' . $uid . '" does not exist.</error>');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$sEmail = $input->getArgument('user');
|
||||
$this->config->setUserValue($uid, 'snappymail', 'snappymail-email', $sEmail);
|
||||
|
||||
$sPass = $input->getArgument('pass');
|
||||
$sPass = ($sEmail && $sPass) ? SnappyMailHelper::encodePassword($sPass, \md5($sEmail)) : '';
|
||||
$this->config->setUserValue($uid, 'snappymail', 'passphrase', $sPass);
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue