From 79ad7ccd0b957d528dfbad7f6377ce2e76eb6d6c Mon Sep 17 00:00:00 2001 From: RainLoop Team Date: Fri, 3 Oct 2014 00:22:06 +0400 Subject: [PATCH] Added allow_universal_login setting (login in to admin panel using main login form) --- dev/App/Abstract.js | 12 +++++-- dev/View/Admin/Settings/Pane.js | 2 +- dev/View/App/Login.js | 4 +++ .../0.0.0/app/libraries/RainLoop/Actions.php | 34 ++++++++++++++++++- .../libraries/RainLoop/Config/Application.php | 1 + 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/dev/App/Abstract.js b/dev/App/Abstract.js index 96a6ce2bc..cdc4d91d8 100644 --- a/dev/App/Abstract.js +++ b/dev/App/Abstract.js @@ -125,10 +125,17 @@ sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') + Settings.settingsGet('Title') || ''; - window.document.title = ''; + window.document.title = sTitle + ' ...'; window.document.title = sTitle; }; + AbstractApp.prototype.redirectToAdminPanel = function () + { + _.delay(function () { + window.location.href = './?/Admin/'; + }, 100); + }; + /** * @param {boolean=} bLogout = false * @param {boolean=} bClose = false @@ -149,7 +156,8 @@ window.close(); } - if (bLogout && '' !== sCustomLogoutLink && window.location.href !== sCustomLogoutLink) + sCustomLogoutLink = sCustomLogoutLink || './'; + if (bLogout && window.location.href !== sCustomLogoutLink) { _.delay(function () { if (bInIframe && window.parent) diff --git a/dev/View/Admin/Settings/Pane.js b/dev/View/Admin/Settings/Pane.js index 4ef5f32d4..4400574b8 100644 --- a/dev/View/Admin/Settings/Pane.js +++ b/dev/View/Admin/Settings/Pane.js @@ -37,7 +37,7 @@ PaneSettingsAdminView.prototype.logoutClick = function () { Remote.adminLogout(function () { - require('App/Admin').loginAndLogoutReload(); + require('App/Admin').loginAndLogoutReload(true); }); }; diff --git a/dev/View/App/Login.js b/dev/View/App/Login.js index 44340b941..aa517f157 100644 --- a/dev/View/App/Login.js +++ b/dev/View/App/Login.js @@ -128,6 +128,10 @@ this.submitRequest(false); } + else if (oData.Admin) + { + require('App/App').redirectToAdminPanel(); + } else { require('App/App').loginAndLogoutReload(); diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 5c0a1a1ea..5b5748540 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -1606,6 +1606,16 @@ class Actions return $sEncryptedData; } + /** + * @param string $sEmail + * + * @return string + */ + private function generateSignMeToken($sEmail) + { + return \md5(\microtime(true).APP_SALT.\rand(10000, 99999).$sEmail); + } + /** * @return array * @@ -1624,11 +1634,33 @@ class Actions $oAccount = null; $sPassword = $this->clientRsaDecryptHelper($sPassword); + $this->Logger()->AddSecret($sPassword); + + if (0 < \strlen($sEmail) && 0 < \strlen($sPassword) && + $this->Config()->Get('security', 'allow_universal_login', true) && + $this->Config()->Get('security', 'allow_admin_panel', true) && + $sEmail === $this->Config()->Get('security', 'admin_login', '') + ) + { + if ($this->Config()->ValidatePassword($sPassword)) + { + $this->setAdminAuthToken($this->getAdminToken()); + + return $this->DefaultResponse(__FUNCTION__, true, array( + 'Admin' => true + )); + } + else + { + $this->loginErrorDelay(); + throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::AuthError); + } + } try { $oAccount = $this->LoginProcess($sEmail, $sPassword, - $bSignMe ? \md5(\microtime(true).APP_SALT.\rand(10000, 99999).$sEmail) : '', + $bSignMe ? $this->generateSignMeToken($sEmail) : '', $sAdditionalCode, $bAdditionalCodeSignMe); } catch (\RainLoop\Exceptions\ClientException $oException) diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 5ade9e68c..42d243498 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -107,6 +107,7 @@ class Application extends \RainLoop\Config\AbstractConfig 'admin_password' => array('12345'), 'allow_admin_panel' => array(true, 'Access settings'), 'allow_two_factor_auth' => array(false), + 'allow_universal_login' => array(true), 'admin_panel_host' => array(''), 'core_install_access_domain' => array('') ),