diff --git a/application/config/auth.php b/application/config/auth.php index a704cef5d..2e42a636c 100644 --- a/application/config/auth.php +++ b/application/config/auth.php @@ -16,3 +16,6 @@ $config['authentication_login_pages'] = array( AUTH_LDAP => '/system/Login/usernamePassword', AUTH_SSO => '/system/Login/sso' ); + +// Logout page +$config['authentication_logout_page'] = '/system/Logout'; diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index 3b68f2fe4..7f952f96f 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -1,19 +1,6 @@ VILESCI_RT_VERWALTUNGS_URL = site_url(). "/organisation/Reihungstest"; + $this->VILESCI_RT_VERWALTUNGS_URL = site_url('/organisation/Reihungstest'); // Load models $this->load->model('crm/Reihungstest_model', 'ReihungstestModel'); diff --git a/application/helpers/hlp_session_helper.php b/application/helpers/hlp_session_helper.php index 536800d37..1f6fd5b12 100644 --- a/application/helpers/hlp_session_helper.php +++ b/application/helpers/hlp_session_helper.php @@ -90,10 +90,8 @@ function cleanSession($sessionName) */ function cleanSessionElement($sessionName, $elementName) { - $session = getSession($sessionName); // get the whole session with the given name - - if (isset($session[$elementName])) + if (isset($_SESSION[$sessionName][$elementName])) { - unset($session[$elementName]); + unset($_SESSION[$sessionName][$elementName]); } } diff --git a/application/libraries/AuthLib.php b/application/libraries/AuthLib.php index fa91f83c6..10a36439e 100644 --- a/application/libraries/AuthLib.php +++ b/application/libraries/AuthLib.php @@ -11,6 +11,7 @@ class AuthLib const AUTHENTICATION_FOREIGN_METHODS = 'authentication_foreign_methods'; const AUTHENTICATION_LOGIN = 'authentication_login'; const AUTHENTICATION_LOGIN_PAGES = 'authentication_login_pages'; + const AUTHENTICATION_LOGOUT_PAGE = 'authentication_logout_page'; // Login object properties const AO_PERSON_ID = 'person_id'; @@ -22,6 +23,7 @@ class AuthLib const SESSION_NAME = 'AUTH'; const SESSION_AUTH_OBJ = 'AUTH_OBJ'; const SESSION_AUTH_OBJ_ORIGIN = 'AUTH_OBJ_ORIGIN'; + const SESSION_LANDING_PAGE = 'LANDING_PAGE'; private $_ci; // CI instance @@ -125,12 +127,38 @@ class AuthLib // If were possible to retrieve user's data without failing, // then stores the authentication object into authentication session - if (isSuccess($loginUP)) $this->_storeAuthObj(getData($loginUP)); + if (isSuccess($loginUP)) $this->_storeSessionAuthObj(getData($loginUP)); } return $loginUP; } + /** + * Redirect to the previously stored landing page + */ + public function redirectToLandingPage($altLandingPage = null) + { + // Tries to get the previously stored landing page + $landingPage = getSessionElement(self::SESSION_NAME, self::SESSION_LANDING_PAGE); + if ($landingPage == null) // if not present + { + // If it was given a valid alternative landing page + if (!isEmptyString($altLandingPage)) + { + $landingPage = $altLandingPage; + } + else + { + $landingPage = site_url(); // use the default home page + } + } + + // Clean the previously stored landing page + cleanSessionElement(self::SESSION_NAME, self::SESSION_LANDING_PAGE); + + $this->_redirectTemporarily($landingPage); // redirect to landing page + } + /** * Checks the authentication of an addon. Returns TRUE if valid, otherwise FALSE */ @@ -380,26 +408,42 @@ class AuthLib /** * Stores the authentication object into the authentication session */ - private function _storeAuthObj($authObj) + private function _storeSessionAuthObj($authObj) { setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ, $authObj); // authentication object setSessionElement(self::SESSION_NAME, self::SESSION_AUTH_OBJ_ORIGIN, $authObj); // authentication original object } + /** + * Stores the user accessed point into the authentication session + */ + private function _storeSessionLandingPage($loginPage, $logoutPage) + { + // Build the curret URL (user access point) + $currentURL = current_url().(!isEmptyString($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : ''); + + // If the access point is not the login page or the logout page + if ($currentURL != site_url($loginPage) && $currentURL != site_url($logoutPage)) + { + setSessionElement(self::SESSION_NAME, self::SESSION_LANDING_PAGE, $currentURL); + } + } + /** * Redirect the user's browser to the configured login page */ private function _redirectToLogin() { $al = $this->_ci->config->item(self::AUTHENTICATION_LOGIN); // selected login method - $alp = $this->_ci->config->item(self::AUTHENTICATION_LOGIN_PAGES); // login pages configuration array + $alip = $this->_ci->config->item(self::AUTHENTICATION_LOGIN_PAGES); // login pages configuration array + $alop = $this->_ci->config->item(self::AUTHENTICATION_LOGOUT_PAGE); // logout page configuration // If the configuration is valid - if (!isEmptyArray($alp) && isset($alp[$al])) + if (!isEmptyArray($alip) && isset($alip[$al])) { - header('HTTP/1.1 302 Moved temporary'); // temporary redirection - header('Location: '.site_url().$alp[$al]); // redirect to the configured login page - exit(); // stops execution! + $this->_storeSessionLandingPage($alip[$al], $alop); // stores in session the user access point + + $this->_redirectTemporarily(site_url($alip[$al])); // redirect to login page } else { @@ -421,7 +465,7 @@ class AuthLib $auth = $this->_checkForeignAuthentication(); if (hasData($auth)) // Authenticated with a foreign authentication method { - $this->_storeAuthObj(getData($auth)); // store the session authentication object + $this->_storeSessionAuthObj(getData($auth)); // store the session authentication object } elseif (getCode($auth) == AUTH_NOT_AUTHENTICATED) // if no foreign authentication was found... { @@ -473,6 +517,17 @@ class AuthLib return $authObj; } + /** + * HTTP temporary redirection + */ + private function _redirectTemporarily($url) + { + // Temporary redirection + header('HTTP/1.1 302 Moved temporary'); + header('Location: '.$url); // redirect to the given URL + exit(); // stops execution! + } + /** * Returns all the keys with which is possible to obtain personal data about a final user * using the given username (uid) diff --git a/application/views/system/messages/messageWriteReply.php b/application/views/system/messages/messageWriteReply.php index 420b008be..344871b2d 100644 --- a/application/views/system/messages/messageWriteReply.php +++ b/application/views/system/messages/messageWriteReply.php @@ -15,7 +15,7 @@ $this->load->view( ?>