diff --git a/application/loginbasic.class.inc.php b/application/loginbasic.class.inc.php index 684f1ec2c..6460dad92 100644 --- a/application/loginbasic.class.inc.php +++ b/application/loginbasic.class.inc.php @@ -34,6 +34,17 @@ class LoginBasic extends AbstractLoginFSMExtension return LoginWebPage::LOGIN_FSM_CONTINUE; } + protected function OnReadCredentials(&$iErrorCode) + { + if ($_SESSION['login_mode'] == 'basic') + { + list($sAuthUser, $sAuthPwd) = $this->GetAuthUserAndPassword(); + $_SESSION['login_temp_auth_user'] = $sAuthUser; + } + return LoginWebPage::LOGIN_FSM_CONTINUE; + } + + protected function OnCheckCredentials(&$iErrorCode) { if ($_SESSION['login_mode'] == 'basic') diff --git a/application/logindefault.class.inc.php b/application/logindefault.class.inc.php index 5227efe14..7751b48b6 100644 --- a/application/logindefault.class.inc.php +++ b/application/logindefault.class.inc.php @@ -22,6 +22,9 @@ class LoginDefaultBefore extends AbstractLoginFSMExtension protected function OnStart(&$iErrorCode) { $iErrorCode = LoginWebPage::EXIT_CODE_OK; + + unset($_SESSION['login_temp_auth_user']); + // Check if proposed login mode is present and allowed $aAllowedLoginTypes = MetaModel::GetConfig()->GetAllowedLoginTypes(); $sProposedLoginMode = utils::ReadParam('login_mode', ''); @@ -105,6 +108,12 @@ class LoginDefaultAfter extends AbstractLoginFSMExtension implements iLogoutExte self::ResetLoginSession(); } + protected function OnConnected(&$iErrorCode) + { + unset($_SESSION['login_temp_auth_user']); + return LoginWebPage::LOGIN_FSM_CONTINUE; + } + // Hard reset of the session private static function ResetLoginSession() { diff --git a/application/loginform.class.inc.php b/application/loginform.class.inc.php index e7847fd7a..ae53f911e 100644 --- a/application/loginform.class.inc.php +++ b/application/loginform.class.inc.php @@ -44,6 +44,8 @@ class LoginForm extends AbstractLoginFSMExtension implements iLoginDataExtension $this->bForceFormOnError = false; exit; } + + $_SESSION['login_temp_auth_user'] = $sAuthUser; $_SESSION['login_mode'] = 'form'; } return LoginWebPage::LOGIN_FSM_CONTINUE; diff --git a/application/logintwig.class.inc.php b/application/logintwig.class.inc.php index b072a48d1..ed03ffb46 100644 --- a/application/logintwig.class.inc.php +++ b/application/logintwig.class.inc.php @@ -15,6 +15,8 @@ class LoginTwigData private $aPostedVars; private $sTwigLoaderPath; private $sCSSFile; + /** @var array */ + private $aJsFiles; /** * LoginTwigData constructor. @@ -22,13 +24,15 @@ class LoginTwigData * @param array $aPostedVars * @param string $sLoaderPath * @param string $sCSSFile + * @param array $aJsFiles */ - public function __construct($aPostedVars = array(), $sLoaderPath = null, $sCSSFile = null) + public function __construct($aPostedVars = array(), $sLoaderPath = null, $sCSSFile = null, $aJsFiles = array()) { $this->aBlockData = array(); $this->aPostedVars = $aPostedVars; $this->sTwigLoaderPath = $sLoaderPath; $this->sCSSFile = $sCSSFile; + $this->aJsFiles = $aJsFiles; } /** @@ -61,6 +65,14 @@ class LoginTwigData { return $this->sCSSFile; } + + /** + * @return array + */ + public function GetJsFiles() + { + return $this->aJsFiles; + } } class LoginBlockData @@ -172,6 +184,12 @@ class LoginTwigContext { $oPage->add_linked_stylesheet($sCSSFile); } + $aJsFiles = $oFormData->GetJsFiles(); + foreach ($aJsFiles as $sJsFile) + { + $oPage->add_linked_script($sJsFile); + + } } } diff --git a/application/loginurl.class.inc.php b/application/loginurl.class.inc.php index b21456c95..8a215e8f5 100644 --- a/application/loginurl.class.inc.php +++ b/application/loginurl.class.inc.php @@ -38,6 +38,15 @@ class LoginURL extends AbstractLoginFSMExtension return LoginWebPage::LOGIN_FSM_CONTINUE; } + protected function OnReadCredentials(&$iErrorCode) + { + if ($_SESSION['login_mode'] == 'url') + { + $_SESSION['login_temp_auth_user'] = utils::ReadParam('auth_user', '', false, 'raw_data'); + } + return LoginWebPage::LOGIN_FSM_CONTINUE; + } + protected function OnCheckCredentials(&$iErrorCode) { if ($_SESSION['login_mode'] == 'url') diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 1eba71157..397d66b59 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -583,6 +583,8 @@ class UserRights protected static $m_oUser; protected static $m_oRealUser; protected static $m_sSelfRegisterAddOn = null; + /** @var array array('sName' => $sName, 'bSuccess' => $bSuccess); */ + private static $m_sLastLoginStatus = null; public static function SelectModule($sModuleName) { @@ -664,20 +666,26 @@ class UserRights if (self::FindUser($sName, $sAuthentication, true) == null) { // User does not exist at all - return self::CheckCredentialsAndCreateUser($sName, $sPassword, $sLoginMode, $sAuthentication); + $bCheckCredentialsAndCreateUser = self::CheckCredentialsAndCreateUser($sName, $sPassword, $sLoginMode, $sAuthentication); + self::$m_sLastLoginStatus = array('sName' => $sName, 'bSuccess' => $bCheckCredentialsAndCreateUser); + return $bCheckCredentialsAndCreateUser; } else { // User is actually disabled + self::$m_sLastLoginStatus = array('sName' => $sName, 'bSuccess' => false); return false; } } if (!$oUser->CheckCredentials($sPassword)) { + self::$m_sLastLoginStatus = array('sName' => $sName, 'bSuccess' => false); return false; } self::UpdateUser($oUser, $sLoginMode, $sAuthentication); + self::$m_sLastLoginStatus = array('sName' => $sName, 'bSuccess' => true); + return true; } @@ -1375,6 +1383,14 @@ class UserRights { return true; // Ignore the error } + + /** + * @return null|array The last login/result (null if none has failed) the array has this structure : array('sName' => $sName, 'bSuccess' => $bSuccess); + */ + public static function GetLastLoginStatus() + { + return self::$m_sLastLoginStatus; + } } /**