mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 07:57:02 +03:00
improve: nextcloud: set 'smremember' cookie if 'sign_me_auto' is set to 'DefaultOn' when using 'snappymail-autologin*', otherwise nextcloud users need to re-login when the browser is re-opened.
This commit is contained in:
parent
35cd354353
commit
79c8281a6b
4 changed files with 16 additions and 6 deletions
|
|
@ -86,7 +86,8 @@ class Application extends App implements IBootstrap
|
||||||
// https://github.com/nextcloud/server/issues/36083#issuecomment-1387370634
|
// https://github.com/nextcloud/server/issues/36083#issuecomment-1387370634
|
||||||
// \OC::$server->getSession()['snappymail-password'] = '';
|
// \OC::$server->getSession()['snappymail-password'] = '';
|
||||||
SnappyMailHelper::loadApp();
|
SnappyMailHelper::loadApp();
|
||||||
\RainLoop\Api::Actions()->Logout(true);
|
// \RainLoop\Api::Actions()->Logout(true);
|
||||||
|
\RainLoop\Api::Actions()->DoLogout();
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/nextcloud/impersonate/issues/179
|
// https://github.com/nextcloud/impersonate/issues/179
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,9 @@ class SnappyMailHelper
|
||||||
if ($doLogin && $aCredentials[1] && $aCredentials[2]) {
|
if ($doLogin && $aCredentials[1] && $aCredentials[2]) {
|
||||||
try {
|
try {
|
||||||
$oActions->Logger()->AddSecret($aCredentials[2]);
|
$oActions->Logger()->AddSecret($aCredentials[2]);
|
||||||
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2], false);
|
|
||||||
|
$bSignMe = $oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DEFAULT_OFF) === \RainLoop\Enumerations\SignMeType::DEFAULT_ON;
|
||||||
|
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2], $bSignMe);
|
||||||
if ($oAccount) {
|
if ($oAccount) {
|
||||||
$oActions->Plugins()->RunHook('login.success', array($oAccount));
|
$oActions->Plugins()->RunHook('login.success', array($oAccount));
|
||||||
$oActions->SetAuthToken($oAccount);
|
$oActions->SetAuthToken($oAccount);
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,14 @@ trait UserAuth
|
||||||
|
|
||||||
$this->imapConnect($oAccount, true);
|
$this->imapConnect($oAccount, true);
|
||||||
if ($bMainAccount) {
|
if ($bMainAccount) {
|
||||||
$bSignMe && $this->SetSignMeToken($oAccount);
|
if($bSignMe){
|
||||||
|
// SetAuthToken token needs to be called before SetSignMeToken
|
||||||
|
// because $_COOKIE['smctoken'] is used by Crypt::Passphrase.
|
||||||
|
// If the $_COOKIE['smctoken'] is not set then SetSignMeToken
|
||||||
|
// throws an exception
|
||||||
|
$this->SetAuthToken($oAccount);
|
||||||
|
$this->SetSignMeToken($oAccount);
|
||||||
|
}
|
||||||
$this->StorageProvider()->Put($oAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
|
$this->StorageProvider()->Put($oAccount, StorageType::SESSION, Utils::GetSessionToken(), 'true');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ class Cookies
|
||||||
if ($cookie_remove) {
|
if ($cookie_remove) {
|
||||||
\header_remove('Set-Cookie');
|
\header_remove('Set-Cookie');
|
||||||
foreach ($cookies as $cookie) {
|
foreach ($cookies as $cookie) {
|
||||||
\header($cookie);
|
\header($cookie,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,14 +118,14 @@ class Cookies
|
||||||
foreach (\str_split($sValue, $iMaxSize) as $i => $sPart) {
|
foreach (\str_split($sValue, $iMaxSize) as $i => $sPart) {
|
||||||
$sCookieName = $i ? "{$sName}~{$i}" : $sName;
|
$sCookieName = $i ? "{$sName}~{$i}" : $sName;
|
||||||
Log::debug('COOKIE', "set {$sCookieName}");
|
Log::debug('COOKIE', "set {$sCookieName}");
|
||||||
static::_set($sCookieName, $sPart, $iExpire);
|
static::_set($sCookieName, $sPart, $iExpire, $httponly);
|
||||||
}
|
}
|
||||||
// Delete unused old 4K split cookie parts
|
// Delete unused old 4K split cookie parts
|
||||||
foreach (\array_keys($_COOKIE) as $sCookieName) {
|
foreach (\array_keys($_COOKIE) as $sCookieName) {
|
||||||
$aSplit = \explode('~', $sCookieName);
|
$aSplit = \explode('~', $sCookieName);
|
||||||
if (isset($aSplit[1]) && $aSplit[0] == $sName && $aSplit[1] > $i) {
|
if (isset($aSplit[1]) && $aSplit[0] == $sName && $aSplit[1] > $i) {
|
||||||
Log::debug('COOKIE', "unset {$sCookieName}");
|
Log::debug('COOKIE', "unset {$sCookieName}");
|
||||||
static::_set($sCookieName, '', 0);
|
static::_set($sCookieName, '', 0, $httponly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue