mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 00:47:04 +03:00
Resolve #161 part 2
This commit is contained in:
parent
ac5daa5c22
commit
779e7c7685
1 changed files with 6 additions and 4 deletions
|
|
@ -241,10 +241,11 @@ trait Contacts
|
||||||
|
|
||||||
public function setContactsSyncData(\RainLoop\Model\Account $oAccount, array $aData) : bool
|
public function setContactsSyncData(\RainLoop\Model\Account $oAccount, array $aData) : bool
|
||||||
{
|
{
|
||||||
|
$oMainAccount = $this->getAccountFromToken();
|
||||||
if ($aData['Password']) {
|
if ($aData['Password']) {
|
||||||
$aData['Password'] = \SnappyMail\Crypt::EncryptToJSON($aData['Password'], $oAccount->CryptKey());
|
$aData['Password'] = \SnappyMail\Crypt::EncryptToJSON($aData['Password'], $oMainAccount->CryptKey());
|
||||||
}
|
}
|
||||||
$aData['PasswordHMAC'] = $aData['Password'] ? \hash_hmac('sha1', $aData['Password'], $oAccount->CryptKey()) : null;
|
$aData['PasswordHMAC'] = $aData['Password'] ? \hash_hmac('sha1', $aData['Password'], $oMainAccount->CryptKey()) : null;
|
||||||
return $this->StorageProvider()->Put(
|
return $this->StorageProvider()->Put(
|
||||||
$oAccount,
|
$oAccount,
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
|
|
@ -263,15 +264,16 @@ trait Contacts
|
||||||
$aData = \json_decode($sData);
|
$aData = \json_decode($sData);
|
||||||
if ($aData) {
|
if ($aData) {
|
||||||
if ($aData['Password']) {
|
if ($aData['Password']) {
|
||||||
|
$oMainAccount = $this->getAccountFromToken();
|
||||||
// Verify oAccount password hasn't changed so that Password can be decrypted
|
// Verify oAccount password hasn't changed so that Password can be decrypted
|
||||||
if ($aData['PasswordHMAC'] !== \hash_hmac('sha1', $aData['Password'], $oAccount->CryptKey())) {
|
if ($aData['PasswordHMAC'] !== \hash_hmac('sha1', $aData['Password'], $oMainAccount->CryptKey())) {
|
||||||
// Failed
|
// Failed
|
||||||
$aData['Password'] = null;
|
$aData['Password'] = null;
|
||||||
} else {
|
} else {
|
||||||
// Success
|
// Success
|
||||||
$aData['Password'] = \SnappyMail\Crypt::DecryptFromJSON(
|
$aData['Password'] = \SnappyMail\Crypt::DecryptFromJSON(
|
||||||
$aData['Password'],
|
$aData['Password'],
|
||||||
$oAccount->CryptKey()
|
$oMainAccount->CryptKey()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue