From 4097e4e733215da953185197f045bca535ced12d Mon Sep 17 00:00:00 2001 From: djmaze Date: Tue, 14 Dec 2021 14:16:36 +0100 Subject: [PATCH] Test login on account switching --- .../app/libraries/RainLoop/Actions/User.php | 5 ++--- .../app/libraries/RainLoop/Actions/UserAuth.php | 16 ++++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php index 134136022..8e8c73e05 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php @@ -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', ''); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php index a7c80d079..d70ece56f 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/UserAuth.php @@ -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'); } }