mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Resolve #1543
This commit is contained in:
parent
3ced479ac9
commit
fffc044998
1 changed files with 12 additions and 10 deletions
|
|
@ -14,16 +14,19 @@ class MainAccount extends Account
|
||||||
|
|
||||||
public function resealCryptKey(SensitiveString $oOldPass) : bool
|
public function resealCryptKey(SensitiveString $oOldPass) : bool
|
||||||
{
|
{
|
||||||
$sKey = $this->CryptKey();
|
$oStorage = \RainLoop\Api::Actions()->StorageProvider();
|
||||||
|
$sKey = $oStorage->Get($this, StorageType::ROOT, '.cryptkey');
|
||||||
if ($sKey) {
|
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) {
|
if ($sKey) {
|
||||||
\RainLoop\Api::Actions()->StorageProvider()->Put($this, StorageType::ROOT, '.cryptkey', $sKey);
|
$this->sCryptKey = null;
|
||||||
$sKey = \SnappyMail\Crypt::DecryptFromJSON($sKey, $this->IncPassword());
|
if (\RainLoop\Api::Actions()->StorageProvider()->Put($this, StorageType::ROOT, '.cryptkey', $sKey)) {
|
||||||
if ($sKey) {
|
return true;
|
||||||
$this->sCryptKey = new SensitiveString(\hex2bin($sKey));
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -44,11 +47,10 @@ class MainAccount extends Account
|
||||||
$oStorage->Put($this, StorageType::ROOT, '.cryptkey', $sKey);
|
$oStorage->Put($this, StorageType::ROOT, '.cryptkey', $sKey);
|
||||||
}
|
}
|
||||||
$sKey = \SnappyMail\Crypt::DecryptFromJSON($sKey, $this->IncPassword());
|
$sKey = \SnappyMail\Crypt::DecryptFromJSON($sKey, $this->IncPassword());
|
||||||
if ($sKey) {
|
if (!$sKey) {
|
||||||
$this->sCryptKey = new SensitiveString(\hex2bin($sKey));
|
|
||||||
} else {
|
|
||||||
throw new ClientException(Notifications::CryptKeyError);
|
throw new ClientException(Notifications::CryptKeyError);
|
||||||
}
|
}
|
||||||
|
$this->sCryptKey = new SensitiveString(\hex2bin($sKey));
|
||||||
}
|
}
|
||||||
return $this->sCryptKey;
|
return $this->sCryptKey;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue