Test login on account switching

This commit is contained in:
djmaze 2021-12-14 14:16:36 +01:00
parent 9ba11c77eb
commit 4097e4e733
2 changed files with 12 additions and 9 deletions

View file

@ -215,9 +215,8 @@ trait User
$bMainCache = false;
$bFilesCache = false;
$iOneDay1 = 60 * 60 * 23;
$iOneDay2 = 60 * 60 * 25;
$iOneDay3 = 60 * 60 * 30;
$iOneDay1 = 3600 * 23;
$iOneDay2 = 3600 * 25;
$sTimers = $this->StorageProvider()->Get(null,
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY, 'Cache/Timers', '');

View file

@ -161,9 +161,9 @@ trait UserAuth
$this->Http()->ServerNoCache();
$oMainAccount = $this->getMainAccountFromToken(false);
if ($sEmail && $oMainAccount && $this->GetCapa(false, \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS, $oMainAccount)) {
$oAccountToLogin = null;
$oAccount = null;
if ($oMainAccount->Email() === $sEmail) {
$this->SetAdditionalAuthToken($oAccountToLogin);
$this->SetAdditionalAuthToken($oAccount);
return true;
}
$sEmail = \MailSo\Base\Utils::IdnToAscii($sEmail);
@ -171,16 +171,17 @@ trait UserAuth
if (!isset($aAccounts[$sEmail])) {
throw new ClientException(Notifications::AccountDoesNotExist);
}
$oAccountToLogin = AdditionalAccount::NewInstanceFromTokenArray(
$oAccount = AdditionalAccount::NewInstanceFromTokenArray(
$this, $aAccounts[$sEmail]
);
if (!$oAccountToLogin) {
if (!$oAccount) {
throw new ClientException(Notifications::AccountSwitchFailed);
}
// $this->CheckMailConnection($oAccountToLogin);
// Test the login
$this->CheckMailConnection($oAccount);
$this->SetAdditionalAuthToken($oAccountToLogin);
$this->SetAdditionalAuthToken($oAccount);
return true;
}
return false;
@ -248,9 +249,11 @@ trait UserAuth
} else {
$oMainAuthAccount && $this->StorageProvider()->Clear($oMainAuthAccount, StorageType::SESSION, $sToken);
Utils::ClearCookie(Utils::SESSION_TOKEN);
$this->SetSpecLogoutCustomMgsWithDeletion('Session gone');
$this->Logout(true);
}
} else {
$this->SetSpecLogoutCustomMgsWithDeletion('Session undefined');
$this->Logout(true);
}
} else {
@ -265,6 +268,7 @@ trait UserAuth
}
if ($this->oMainAuthAccount) {
// Extend session cookie lifetime
$this->StorageProvider()->Put($this->oMainAuthAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
}
}