From 7c362879edb3adff196c62f68bc9f1a2593fec58 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Thu, 3 Nov 2022 16:15:42 +0100 Subject: [PATCH] Disable Nextcloud Impersonate check #561 --- .../snappymail/lib/Controller/PageController.php | 2 -- .../snappymail/lib/Util/SnappyMailHelper.php | 13 +++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/integrations/nextcloud/snappymail/lib/Controller/PageController.php b/integrations/nextcloud/snappymail/lib/Controller/PageController.php index f6954e2be1..e13b8f4a64 100644 --- a/integrations/nextcloud/snappymail/lib/Controller/PageController.php +++ b/integrations/nextcloud/snappymail/lib/Controller/PageController.php @@ -24,7 +24,6 @@ public function index() $bAdmin = \RainLoop\Api::Config()->Get('security', 'admin_panel_key', 'admin') == $_SERVER['QUERY_STRING']; if (!$bAdmin) { SnappyMailHelper::startApp(true); - return; } } @@ -58,7 +57,6 @@ public function index() public function appGet() { SnappyMailHelper::startApp(true); - exit; } /** diff --git a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php index 2b461e1adf..5f12a4cd16 100644 --- a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php +++ b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php @@ -103,26 +103,27 @@ public static function startApp(bool $handle = false) : void } else { $doLogin = !$oActions->getMainAccountFromToken(false); $aCredentials = static::getLoginCredentials(); +/* // https://github.com/the-djmaze/snappymail/issues/561#issuecomment-1301317723 + // https://github.com/nextcloud/server/issues/34935#issuecomment-1302145157 // $ocSession['snappymail-uid'] Always NULL, so we use a cookie // $ocSession = \OC::$server->getSession(); // if (!$doLogin && $ocSession['snappymail-uid'] && $ocSession['snappymail-uid'] != $aCredentials[0]) { - if (!$doLogin && !empty($_COOKIE['snappymail-uid']) && $_COOKIE['snappymail-uid'] != $aCredentials[0]) { + if (!$doLogin && !empty($_COOKIE['sm-nc-uid']) && $_COOKIE['sm-nc-uid'] != $aCredentials[0]) { // UID changed, Impersonate plugin probably active - \setcookie('snappymail-uid'); + \RainLoop\Utils::ClearCookie('sm-nc-uid'); $oActions->Logout(true); $doLogin = true; -// $this->logger->warning("Logout {$_COOKIE['snappymail-uid']}", ['app' => 'SnappyMail']); } -// $ocSession['snappymail-uid'] = $aCredentials[0]; - \setcookie('snappymail-uid', $aCredentials[0]); +// $ocSession->set('snappymail-uid', $aCredentials[0]); + \RainLoop\Utils::SetCookie('snappymail-uid', $aCredentials[0]); +*/ if ($doLogin && $aCredentials[1] && $aCredentials[2]) { $oActions->Logger()->AddSecret($aCredentials[2]); $oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2], false); if ($oAccount) { $oActions->Plugins()->RunHook('login.success', array($oAccount)); $oActions->SetAuthToken($oAccount); -// $this->logger->warning("Login {$aCredentials[0]}", ['app' => 'SnappyMail']); } } }