mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 15:45:55 +08:00
Resolve #1543
This commit is contained in:
parent
3ced479ac9
commit
fffc044998
|
@ -14,16 +14,19 @@ class MainAccount extends Account
|
|||
|
||||
public function resealCryptKey(SensitiveString $oOldPass) : bool
|
||||
{
|
||||
$sKey = $this->CryptKey();
|
||||
$oStorage = \RainLoop\Api::Actions()->StorageProvider();
|
||||
$sKey = $oStorage->Get($this, StorageType::ROOT, '.cryptkey');
|
||||
if ($sKey) {
|
||||
$sKey = \SnappyMail\Crypt::EncryptToJSON(\bin2hex($sKey), $this->IncPassword());
|
||||
$sKey = \SnappyMail\Crypt::DecryptFromJSON($sKey, $oOldPass);
|
||||
if (!$sKey) {
|
||||
throw new ClientException(Notifications::CryptKeyError);
|
||||
}
|
||||
$sKey = \SnappyMail\Crypt::EncryptToJSON($sKey, $this->IncPassword());
|
||||
if ($sKey) {
|
||||
\RainLoop\Api::Actions()->StorageProvider()->Put($this, StorageType::ROOT, '.cryptkey', $sKey);
|
||||
$sKey = \SnappyMail\Crypt::DecryptFromJSON($sKey, $this->IncPassword());
|
||||
if ($sKey) {
|
||||
$this->sCryptKey = new SensitiveString(\hex2bin($sKey));
|
||||
$this->sCryptKey = null;
|
||||
if (\RainLoop\Api::Actions()->StorageProvider()->Put($this, StorageType::ROOT, '.cryptkey', $sKey)) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -44,11 +47,10 @@ class MainAccount extends Account
|
|||
$oStorage->Put($this, StorageType::ROOT, '.cryptkey', $sKey);
|
||||
}
|
||||
$sKey = \SnappyMail\Crypt::DecryptFromJSON($sKey, $this->IncPassword());
|
||||
if ($sKey) {
|
||||
$this->sCryptKey = new SensitiveString(\hex2bin($sKey));
|
||||
} else {
|
||||
if (!$sKey) {
|
||||
throw new ClientException(Notifications::CryptKeyError);
|
||||
}
|
||||
$this->sCryptKey = new SensitiveString(\hex2bin($sKey));
|
||||
}
|
||||
return $this->sCryptKey;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue