mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Nextcloud changed stored password handling
This commit is contained in:
parent
56950b4b70
commit
46bd6d4564
3 changed files with 13 additions and 5 deletions
|
|
@ -103,7 +103,7 @@ class FetchController extends Controller {
|
|||
|
||||
$sPass = $_POST['snappymail-password'];
|
||||
if ('******' !== $sPass) {
|
||||
$this->config->setUserValue($sUser, 'snappymail', 'snappymail-password',
|
||||
$this->config->setUserValue($sUser, 'snappymail', 'passphrase',
|
||||
$sPass ? SnappyMailHelper::encodePassword($sPass, \md5($sEmail)) : '');
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,15 +24,19 @@ class PersonalSettings implements ISettings
|
|||
$sEmail = $aRainLoop[0];
|
||||
$this->config->setUserValue($uid, 'snappymail', 'snappymail-email', $sEmail);
|
||||
if ($aRainLoop[1]) {
|
||||
$this->config->setUserValue($uid, 'snappymail', 'snappymail-password',
|
||||
$this->config->setUserValue($uid, 'snappymail', 'passphrase',
|
||||
\OCA\SnappyMail\Util\SnappyMailHelper::encodePassword($aRainLoop[1], \md5($sEmail))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($sPass = $this->config->getUserValue($uid, 'snappymail', 'snappymail-password')) {
|
||||
$this->config->deleteUserValue($uid, 'snappymail', 'snappymail-password');
|
||||
$this->config->setUserValue($uid, 'snappymail', 'passphrase', $sPass);
|
||||
}
|
||||
$parameters = [
|
||||
'snappymail-email' => $sEmail,
|
||||
'snappymail-password' => $this->config->getUserValue($uid, 'snappymail', 'snappymail-password') ? '******' : ''
|
||||
'snappymail-password' => $this->config->getUserValue($uid, 'snappymail', 'passphrase') ? '******' : ''
|
||||
];
|
||||
\OCP\Util::addScript('snappymail', 'snappymail');
|
||||
return new TemplateResponse('snappymail', 'personal_settings', $parameters, '');
|
||||
|
|
|
|||
|
|
@ -106,7 +106,8 @@ class SnappyMailHelper
|
|||
// Login failure, reset password to prevent more attempts
|
||||
$sUID = \OC::$server->getUserSession()->getUser()->getUID();
|
||||
\OC::$server->getSession()['snappymail-passphrase'] = '';
|
||||
\OC::$server->getConfig()->setUserValue($sUID, 'snappymail', 'snappymail-password', '');
|
||||
\OC::$server->getConfig()->setUserValue($sUID, 'snappymail', 'passphrase', '');
|
||||
\SnappyMail\Log::error('Nextcloud', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -132,11 +133,14 @@ class SnappyMailHelper
|
|||
// If the user has set credentials for SnappyMail in their personal settings,
|
||||
// this has the first priority.
|
||||
$sEmail = $config->getUserValue($sUID, 'snappymail', 'snappymail-email');
|
||||
$sPassword = $config->getUserValue($sUID, 'snappymail', 'snappymail-password');
|
||||
$sPassword = $config->getUserValue($sUID, 'snappymail', 'passphrase')
|
||||
?: $config->getUserValue($sUID, 'snappymail', 'snappymail-password');
|
||||
if ($sEmail && $sPassword) {
|
||||
$sPassword = static::decodePassword($sPassword, \md5($sEmail));
|
||||
if ($sPassword) {
|
||||
return [$sUID, $sEmail, $sPassword];
|
||||
} else {
|
||||
\SnappyMail\Log::debug('Nextcloud', 'decodePassword failed for getUserValue');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue