mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 14:37:02 +03:00
Test login on account switching
This commit is contained in:
parent
9ba11c77eb
commit
4097e4e733
2 changed files with 12 additions and 9 deletions
|
|
@ -215,9 +215,8 @@ trait User
|
||||||
$bMainCache = false;
|
$bMainCache = false;
|
||||||
$bFilesCache = false;
|
$bFilesCache = false;
|
||||||
|
|
||||||
$iOneDay1 = 60 * 60 * 23;
|
$iOneDay1 = 3600 * 23;
|
||||||
$iOneDay2 = 60 * 60 * 25;
|
$iOneDay2 = 3600 * 25;
|
||||||
$iOneDay3 = 60 * 60 * 30;
|
|
||||||
|
|
||||||
$sTimers = $this->StorageProvider()->Get(null,
|
$sTimers = $this->StorageProvider()->Get(null,
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', '');
|
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', '');
|
||||||
|
|
|
||||||
|
|
@ -161,9 +161,9 @@ trait UserAuth
|
||||||
$this->Http()->ServerNoCache();
|
$this->Http()->ServerNoCache();
|
||||||
$oMainAccount = $this->getMainAccountFromToken(false);
|
$oMainAccount = $this->getMainAccountFromToken(false);
|
||||||
if ($sEmail && $oMainAccount && $this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS, $oMainAccount)) {
|
if ($sEmail && $oMainAccount && $this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS, $oMainAccount)) {
|
||||||
$oAccountToLogin = null;
|
$oAccount = null;
|
||||||
if ($oMainAccount->Email() === $sEmail) {
|
if ($oMainAccount->Email() === $sEmail) {
|
||||||
$this->SetAdditionalAuthToken($oAccountToLogin);
|
$this->SetAdditionalAuthToken($oAccount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
|
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
|
||||||
|
|
@ -171,16 +171,17 @@ trait UserAuth
|
||||||
if (!isset($aAccounts[$sEmail])) {
|
if (!isset($aAccounts[$sEmail])) {
|
||||||
throw new ClientException(Notifications::AccountDoesNotExist);
|
throw new ClientException(Notifications::AccountDoesNotExist);
|
||||||
}
|
}
|
||||||
$oAccountToLogin = AdditionalAccount::NewInstanceFromTokenArray(
|
$oAccount = AdditionalAccount::NewInstanceFromTokenArray(
|
||||||
$this, $aAccounts[$sEmail]
|
$this, $aAccounts[$sEmail]
|
||||||
);
|
);
|
||||||
if (!$oAccountToLogin) {
|
if (!$oAccount) {
|
||||||
throw new ClientException(Notifications::AccountSwitchFailed);
|
throw new ClientException(Notifications::AccountSwitchFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->CheckMailConnection($oAccountToLogin);
|
// Test the login
|
||||||
|
$this->CheckMailConnection($oAccount);
|
||||||
|
|
||||||
$this->SetAdditionalAuthToken($oAccountToLogin);
|
$this->SetAdditionalAuthToken($oAccount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -248,9 +249,11 @@ trait UserAuth
|
||||||
} else {
|
} else {
|
||||||
$oMainAuthAccount && $this->StorageProvider()->Clear($oMainAuthAccount, StorageType::SESSION, $sToken);
|
$oMainAuthAccount && $this->StorageProvider()->Clear($oMainAuthAccount, StorageType::SESSION, $sToken);
|
||||||
Utils::ClearCookie(Utils::SESSION_TOKEN);
|
Utils::ClearCookie(Utils::SESSION_TOKEN);
|
||||||
|
$this->SetSpecLogoutCustomMgsWithDeletion('Session gone');
|
||||||
$this->Logout(true);
|
$this->Logout(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$this->SetSpecLogoutCustomMgsWithDeletion('Session undefined');
|
||||||
$this->Logout(true);
|
$this->Logout(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -265,6 +268,7 @@ trait UserAuth
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->oMainAuthAccount) {
|
if ($this->oMainAuthAccount) {
|
||||||
|
// Extend session cookie lifetime
|
||||||
$this->StorageProvider()->Put($this->oMainAuthAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
|
$this->StorageProvider()->Put($this->oMainAuthAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue