/** * Check if user login is required. If so, use login handler to redirect user. * * @deprecated As of 4.4, moved to {@link eZUserLoginHandler::preCheck()} * @param array $siteBasics * @param eZURI $uri * @return array|true|false|null An associative array on redirect with 'module' and 'function' keys, true on successful * and false/null on #fail. */ function eZCheckUser(array &$siteBasics, eZURI $uri) { if (!$siteBasics['user-object-required']) { return null; } $ini = eZINI::instance(); $requireUserLogin = $ini->variable('SiteAccessSettings', 'RequireUserLogin') == 'true'; $forceLogin = false; if (eZSession::hasStarted()) { $http = eZHTTPTool::instance(); $forceLogin = $http->hasSessionVariable(eZUserLoginHandler::FORCE_LOGIN); } if (!$requireUserLogin && !$forceLogin) { return null; } return eZUserLoginHandler::checkUser($siteBasics, $uri); }
/** * Check if user login is required. If so, use login handler to redirect user. * * @deprecated As of 4.4, moved to {@link eZUserLoginHandler::preCheck()} * @param array $siteBasics * @param eZURI $uri * @return array|true|false|null An associative array on redirect with 'module' and 'function' keys, true on successful * and false/null on #fail. */ function eZCheckUser(array &$siteBasics, eZURI $uri) { eZDebug::writeStrict('Function eZCheckUser() has been deprecated in 4.4 in favor of eZUserLoginHandler::preCheck()', 'Deprecation'); if (!$siteBasics['user-object-required']) { return null; } $ini = eZINI::instance(); $requireUserLogin = $ini->variable('SiteAccessSettings', 'RequireUserLogin') == 'true'; $forceLogin = false; if (eZSession::hasStarted()) { $http = eZHTTPTool::instance(); $forceLogin = $http->hasSessionVariable(eZUserLoginHandler::FORCE_LOGIN); } if (!$requireUserLogin && !$forceLogin) { return null; } return eZUserLoginHandler::checkUser($siteBasics, $uri); }
static function checkUser(&$siteBasics, &$url) { $http = eZHTTPTool::instance(); if (!$http->hasSessionVariable(self::STEP)) { $http->setSessionVariable(self::STEP, self::STEP_PRE_CHECK_USER_INFO); } $loginStep =& $http->sessionVariable(self::STEP); if ($http->hasSessionVariable(self::FORCE_LOGIN) && $loginStep < self::STEP_PRE_COLLECT_USER_INFO) { $loginStep = self::STEP_PRE_COLLECT_USER_INFO; } switch ($loginStep) { case self::STEP_PRE_CHECK_USER_INFO: $ini = eZINI::instance(); $handlerList = array('standard'); if ($ini->hasVariable('UserSettings', 'LoginHandler')) { $handlerList = $ini->variable('UserSettings', 'LoginHandler'); } if ($http->hasSessionVariable(self::LAST_HANDLER_NAME)) { $http->removeSessionVariable(self::LAST_HANDLER_NAME); } foreach ($handlerList as $handler) { $userObject = eZUserLoginHandler::instance($handler); if ($userObject) { $check = $userObject->checkUser($siteBasics, $url); if ($check === null) { eZUserLoginHandler::sessionCleanup(); return null; } $http->setSessionVariable(self::LAST_CHECK_REDIRECT, $check); $http->setSessionVariable(self::LAST_HANDLER_NAME, $handler); } } $http->setSessionVariable(self::STEP, self::STEP_PRE_COLLECT_USER_INFO); return eZUserLoginHandler::checkUser($siteBasics, $url); break; case self::STEP_PRE_COLLECT_USER_INFO: $http->setSessionVariable(self::STEP, self::STEP_POST_COLLECT_USER_INFO); $handler = null; if ($http->hasSessionVariable(self::LAST_HANDLER_NAME)) { $handlerName = $http->sessionVariable(self::LAST_HANDLER_NAME); $handler = eZUserLoginHandler::instance($handlerName); } if ($handler) { return $handler->preCollectUserInfo(); } else { $redirect =& $http->sessionVariable(self::LAST_CHECK_REDIRECT); if (!$redirect) { $redirect = array('module' => 'user', 'function' => 'login'); } return $redirect; } break; case self::STEP_POST_COLLECT_USER_INFO: $http->setSessionVariable(self::STEP, self::STEP_LOGIN_USER); $handler = null; if ($http->hasSessionVariable(self::LAST_HANDLER_NAME)) { $handlerName = $http->sessionVariable(self::LAST_HANDLER_NAME); $handler = eZUserLoginHandler::instance($handlerName); } if ($handler) { // Use specified login handler to handle Login info input if (!$handler->postCollectUserInfo()) { eZUserLoginHandler::sessionCleanup(); eZHTTPTool::redirect('/'); eZExecution::cleanExit(); } } return eZUserLoginHandler::checkUser($siteBasics, $url); break; case self::STEP_LOGIN_USER: $ini = eZINI::instance(); $handlerList = array('standard'); if ($ini->hasVariable('UserSettings', 'LoginHandler')) { $handlerList = $ini->variable('UserSettings', 'LoginHandler'); } $userInfoArray =& $http->sessionVariable(self::USER_INFO); $http->removeSessionVariable(self::USER_INFO); if ($http->hasSessionVariable(self::FORCE_LOGIN)) { $http->removeSessionVariable(self::FORCE_LOGIN); } $user = null; if (is_array($userInfoArray) and $userInfoArray['login'] and $userInfoArray['password']) { foreach ($handlerList as $handler) { $userObject = eZUserLoginHandler::instance($handler); if ($userObject) { $user = $userObject->loginUser($userInfoArray['login'], $userInfoArray['password']); if (is_subclass_of($user, 'eZUser')) { eZUserLoginHandler::sessionCleanup(); return null; } else { if (is_array($user)) { eZUserLoginHandler::sessionCleanup(); return $user; } } } } } $http->setSessionVariable(self::STEP, self::STEP_PRE_CHECK_USER_INFO); return eZUserLoginHandler::checkUser($siteBasics, $url); break; } }