Skip to content

Commit

Permalink
Disable Nextcloud Impersonate check #561
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Nov 3, 2022
1 parent d3b65af commit 7c36287
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -58,7 +57,6 @@ public function index()
public function appGet()
{
SnappyMailHelper::startApp(true);
exit;
}

/**
Expand Down
13 changes: 7 additions & 6 deletions integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
}
Expand Down

0 comments on commit 7c36287

Please sign in to comment.