mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
SignMe optimizations
This commit is contained in:
parent
c2e3e45845
commit
98e110fcc7
4 changed files with 62 additions and 27 deletions
|
|
@ -148,7 +148,8 @@
|
||||||
'ExpandedFolders': 3,
|
'ExpandedFolders': 3,
|
||||||
'FolderListSize': 4,
|
'FolderListSize': 4,
|
||||||
'MessageListSize': 5,
|
'MessageListSize': 5,
|
||||||
'LastReplyAction': 6
|
'LastReplyAction': 6,
|
||||||
|
'LastSignMe': 7
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
LanguageStore = require('Stores/Language'),
|
LanguageStore = require('Stores/Language'),
|
||||||
AppStore = require('Stores/User/App'),
|
AppStore = require('Stores/User/App'),
|
||||||
|
|
||||||
|
Local = require('Storage/Client'),
|
||||||
Settings = require('Storage/Settings'),
|
Settings = require('Storage/Settings'),
|
||||||
Remote = require('Storage/User/Remote'),
|
Remote = require('Storage/User/Remote'),
|
||||||
|
|
||||||
|
|
@ -215,6 +216,8 @@
|
||||||
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Local.set(Enums.ClientSideKeyName.LastSignMe, !!this.signMe() ? '-1-' : '-0-');
|
||||||
|
|
||||||
}, this)
|
}, this)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
@ -322,6 +325,8 @@
|
||||||
{
|
{
|
||||||
var
|
var
|
||||||
self = this,
|
self = this,
|
||||||
|
sSignMeLocal = Local.get(Enums.ClientSideKeyName.LastSignMe),
|
||||||
|
sSignMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
|
||||||
sJsHash = Settings.settingsGet('JsHash'),
|
sJsHash = Settings.settingsGet('JsHash'),
|
||||||
fSocial = function (iErrorCode) {
|
fSocial = function (iErrorCode) {
|
||||||
iErrorCode = Utils.pInt(iErrorCode);
|
iErrorCode = Utils.pInt(iErrorCode);
|
||||||
|
|
@ -342,13 +347,24 @@
|
||||||
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
|
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
|
||||||
!!Settings.settingsGet('AllowGoogleSocialAuth'));
|
!!Settings.settingsGet('AllowGoogleSocialAuth'));
|
||||||
|
|
||||||
switch ((Settings.settingsGet('SignMe') || 'unused').toLowerCase())
|
switch (sSignMe)
|
||||||
{
|
{
|
||||||
case Enums.LoginSignMeTypeAsString.DefaultOff:
|
case Enums.LoginSignMeTypeAsString.DefaultOff:
|
||||||
this.signMeType(Enums.LoginSignMeType.DefaultOff);
|
|
||||||
break;
|
|
||||||
case Enums.LoginSignMeTypeAsString.DefaultOn:
|
case Enums.LoginSignMeTypeAsString.DefaultOn:
|
||||||
this.signMeType(Enums.LoginSignMeType.DefaultOn);
|
|
||||||
|
this.signMeType(Enums.LoginSignMeTypeAsString.DefaultOn === sSignMe ?
|
||||||
|
Enums.LoginSignMeType.DefaultOn : Enums.LoginSignMeType.DefaultOff);
|
||||||
|
|
||||||
|
switch (sSignMeLocal)
|
||||||
|
{
|
||||||
|
case '-1-':
|
||||||
|
this.signMeType(Enums.LoginSignMeType.DefaultOn);
|
||||||
|
break;
|
||||||
|
case '-0-':
|
||||||
|
this.signMeType(Enums.LoginSignMeType.DefaultOff);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case Enums.LoginSignMeTypeAsString.Unused:
|
case Enums.LoginSignMeTypeAsString.Unused:
|
||||||
|
|
|
||||||
|
|
@ -531,13 +531,21 @@ class Actions
|
||||||
|
|
||||||
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
|
if ($oAccount->SignMe() && 0 < \strlen($oAccount->SignMeToken()))
|
||||||
{
|
{
|
||||||
\RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY, $oAccount->SignMeToken(),
|
\RainLoop\Utils::SetCookie(self::AUTH_SIGN_ME_TOKEN_KEY,
|
||||||
|
\RainLoop\Utils::EncodeKeyValues(array(
|
||||||
|
'e' => $oAccount->Email(),
|
||||||
|
't' => $oAccount->SignMeToken()
|
||||||
|
)),
|
||||||
\time() + 60 * 60 * 24 * 30, '/', null, null, true);
|
\time() + 60 * 60 * 24 * 30, '/', null, null, true);
|
||||||
|
|
||||||
$this->StorageProvider()->Put(null,
|
$this->StorageProvider()->Put($oAccount,
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
\RainLoop\KeyPathHelper::SignMeUserToken($oAccount->SignMeToken()),
|
'sign_me',
|
||||||
$oAccount->GetAuthToken()
|
\RainLoop\Utils::EncodeKeyValues(array(
|
||||||
|
'Time' => \time(),
|
||||||
|
'AuthToken' => $oAccount->GetAuthToken(),
|
||||||
|
'SignMetToken' => $oAccount->SignMeToken()
|
||||||
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1136,10 +1144,30 @@ class Actions
|
||||||
$sSignMeToken = \RainLoop\Utils::GetCookie(\RainLoop\Actions::AUTH_SIGN_ME_TOKEN_KEY, '');
|
$sSignMeToken = \RainLoop\Utils::GetCookie(\RainLoop\Actions::AUTH_SIGN_ME_TOKEN_KEY, '');
|
||||||
if (!empty($sSignMeToken))
|
if (!empty($sSignMeToken))
|
||||||
{
|
{
|
||||||
$oAccount = $this->GetAccountFromCustomToken($this->StorageProvider()->Get(null,
|
$aTokenData = \RainLoop\Utils::DecodeKeyValues($sSignMeToken);
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
if (\is_array($aTokenData) && !empty($aTokenData['e']) && !empty($aTokenData['t']))
|
||||||
\RainLoop\KeyPathHelper::SignMeUserToken($sSignMeToken)
|
{
|
||||||
), false, false);
|
$sTokenSettings = $this->StorageProvider()->Get($aTokenData['e'],
|
||||||
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
|
'sign_me'
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!empty($sTokenSettings))
|
||||||
|
{
|
||||||
|
$aSignMeData = \RainLoop\Utils::DecodeKeyValues($sTokenSettings);
|
||||||
|
if (\is_array($aSignMeData) &&
|
||||||
|
!empty($aSignMeData['AuthToken']) &&
|
||||||
|
!empty($aSignMeData['SignMetToken']) &&
|
||||||
|
$aSignMeData['SignMetToken'] === $aTokenData['t'])
|
||||||
|
{
|
||||||
|
$oAccount = $this->GetAccountFromCustomToken($aSignMeData['AuthToken'], false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SIGN_ME_TOKEN_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $oAccount;
|
return $oAccount;
|
||||||
|
|
@ -2671,9 +2699,9 @@ class Actions
|
||||||
{
|
{
|
||||||
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SIGN_ME_TOKEN_KEY);
|
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::AUTH_SIGN_ME_TOKEN_KEY);
|
||||||
|
|
||||||
$this->StorageProvider()->Clear(null,
|
$this->StorageProvider()->Clear($oAccount,
|
||||||
\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY,
|
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
|
||||||
\RainLoop\KeyPathHelper::SignMeUserToken($oAccount->SignMeToken())
|
'sign_me'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,16 +34,6 @@ class KeyPathHelper
|
||||||
return '/Rsa/Data/'.$sHash.'/';
|
return '/Rsa/Data/'.$sHash.'/';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $sSignMeToken
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
static public function SignMeUserToken($sSignMeToken)
|
|
||||||
{
|
|
||||||
return '/SignMe/UserToken/'.$sSignMeToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $sDomain
|
* @param string $sDomain
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue