mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Cleanup usage of ParentEmail
This commit is contained in:
parent
85ddc5bbb2
commit
aed72f91ee
5 changed files with 6 additions and 29 deletions
|
|
@ -17,7 +17,7 @@ trait Accounts
|
|||
|
||||
protected function GetMainEmail(Account $oAccount)
|
||||
{
|
||||
return $oAccount instanceof AdditionalAccount ? $oAccount->ParentEmail() : $oAccount->Email();
|
||||
return ($oAccount instanceof AdditionalAccount ? $this->getMainAccountFromToken() : $oAccount)->Email();
|
||||
}
|
||||
|
||||
public function GetAccounts(MainAccount $oAccount): array
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ namespace RainLoop\Actions;
|
|||
trait Contacts
|
||||
{
|
||||
|
||||
private function GetAccountParentEmail()
|
||||
{
|
||||
// $oAccount instanceof \RainLoop\Model\AdditionalAccount ? $oAccount->ParentEmail() : $oAccount->Email()
|
||||
}
|
||||
|
||||
public function DoSaveContactsSyncData() : array
|
||||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
|
|
|
|||
|
|
@ -116,9 +116,6 @@ trait UserAuth
|
|||
try {
|
||||
if ($oMainAccount) {
|
||||
$oAccount = AdditionalAccount::NewInstanceByLogin($this, $sEmail, $sLogin, $sPassword, $sClientCert, true);
|
||||
if ($oAccount) {
|
||||
$oAccount->SetParentEmail($oMainAccount->Email());
|
||||
}
|
||||
} else {
|
||||
$oAccount = MainAccount::NewInstanceByLogin($this, $sEmail, $sLogin, $sPassword, $sClientCert, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,30 +7,20 @@ use RainLoop\Exceptions\ClientException;
|
|||
|
||||
class AdditionalAccount extends Account
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sParentEmail = '';
|
||||
|
||||
public function ParentEmail() : string
|
||||
{
|
||||
return $this->sParentEmail;
|
||||
}
|
||||
|
||||
public function SetParentEmail(string $sParentEmail) : void
|
||||
{
|
||||
$this->sParentEmail = \trim(\MailSo\Base\Utils::IdnToAscii($sParentEmail, true));
|
||||
return \trim(\MailSo\Base\Utils::IdnToAscii(\RainLoop\Api::Actions()->getMainAccountFromToken()->Email(), true));
|
||||
}
|
||||
|
||||
public function Hash() : string
|
||||
{
|
||||
return \md5(parent::Hash() . $this->sParentEmail);
|
||||
return \md5(parent::Hash() . $this->ParentEmail());
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$aData = parent::jsonSerialize();
|
||||
$aData[] = $this->sParentEmail;
|
||||
$aData[] = ''; // was ParentEmail
|
||||
return $aData;
|
||||
}
|
||||
|
||||
|
|
@ -53,16 +43,11 @@ class AdditionalAccount extends Account
|
|||
if (!empty($aAccountHash[0]) && 'account' === $aAccountHash[0] && 8 <= $iCount && 9 >= $iCount) {
|
||||
$sHash = $oActions->getMainAccountFromToken()->CryptKey();
|
||||
$sPasswordHMAC = (8 < $iCount) ? \array_pop($aAccountHash) : null;
|
||||
$sParentEmail = \array_pop($aAccountHash);
|
||||
if ($sPasswordHMAC && $sPasswordHMAC === \hash_hmac('sha1', $aAccountHash[3], $sHash)) {
|
||||
$aAccountHash[3] = \SnappyMail\Crypt::DecryptUrlSafe($aAccountHash[3], $sHash);
|
||||
$aAccountHash[6] = \SnappyMail\Crypt::DecryptUrlSafe($aAccountHash[6], $sHash);
|
||||
}
|
||||
$oAccount = parent::NewInstanceFromTokenArray($oActions, $aAccountHash, $bThrowExceptionOnFalse);
|
||||
if ($oAccount) {
|
||||
$oAccount->SetParentEmail($sParentEmail);
|
||||
return $oAccount;
|
||||
}
|
||||
return parent::NewInstanceFromTokenArray($oActions, $aAccountHash, $bThrowExceptionOnFalse);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class FileStorage implements \RainLoop\Providers\Files\IFiles
|
|||
$sEmail = $oAccount->ParentEmail();
|
||||
$sSubEmail = $oAccount->Email();
|
||||
} else {
|
||||
$sEmail = $oAccount->Email() ?: 'nobody@unknown.tld';
|
||||
$sEmail = $oAccount->Email();
|
||||
$sSubEmail = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue