Commit 6c0fcd4ce54cf8dd1ad1377ff861428dd13884bd
1 parent
c6aa932f
KTS-729: Change language even if login fails.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5203 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
80 additions
and
79 deletions
login.php
| ... | ... | @@ -37,19 +37,19 @@ require_once(KT_LIB_DIR . '/authentication/authenticationutil.inc.php'); |
| 37 | 37 | class LoginPageDispatcher extends KTDispatcher { |
| 38 | 38 | |
| 39 | 39 | function check() { |
| 40 | - $this->session = new Session(); | |
| 41 | - if ($this->session->verify() == 1) { // erk. neil - DOUBLE CHECK THIS PLEASE. | |
| 42 | - exit(redirect(generateControllerLink('dashboard'))); | |
| 43 | - } else { | |
| 44 | - $this->session->destroy(); // toast it - its probably a hostile session. | |
| 45 | - } | |
| 46 | - return true; | |
| 47 | - } | |
| 40 | + $this->session = new Session(); | |
| 41 | + if ($this->session->verify() == 1) { // erk. neil - DOUBLE CHECK THIS PLEASE. | |
| 42 | + exit(redirect(generateControllerLink('dashboard'))); | |
| 43 | + } else { | |
| 44 | + $this->session->destroy(); // toast it - its probably a hostile session. | |
| 45 | + } | |
| 46 | + return true; | |
| 47 | + } | |
| 48 | 48 | |
| 49 | 49 | function do_providerVerify() { |
| 50 | - $this->session = new Session(); | |
| 51 | - if ($this->session->verify() != 1) { | |
| 52 | - $this->redirectToMain(); | |
| 50 | + $this->session = new Session(); | |
| 51 | + if ($this->session->verify() != 1) { | |
| 52 | + $this->redirectToMain(); | |
| 53 | 53 | } |
| 54 | 54 | $this->oUser =& User::get($_SESSION['userID']); |
| 55 | 55 | $oProvider =& KTAuthenticationUtil::getAuthenticationProviderForUser($this->oUser); |
| ... | ... | @@ -57,16 +57,16 @@ class LoginPageDispatcher extends KTDispatcher { |
| 57 | 57 | exit(0); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - function do_main() { | |
| 61 | - global $default; | |
| 62 | - | |
| 63 | - $this->check(); // bounce here, potentially. | |
| 64 | - header('Content-type: text/html; charset=UTF-8'); | |
| 65 | - $cookietest = KTUtil::randomString(); | |
| 66 | - setcookie("CookieTestCookie", $cookietest, false); | |
| 67 | - | |
| 68 | - $errorMessage = KTUtil::arrayGet($_REQUEST, 'errorMessage'); | |
| 69 | - $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | |
| 60 | + function do_main() { | |
| 61 | + global $default; | |
| 62 | + | |
| 63 | + $this->check(); // bounce here, potentially. | |
| 64 | + header('Content-type: text/html; charset=UTF-8'); | |
| 65 | + $cookietest = KTUtil::randomString(); | |
| 66 | + setcookie("CookieTestCookie", $cookietest, false); | |
| 67 | + | |
| 68 | + $errorMessage = KTUtil::arrayGet($_REQUEST, 'errorMessage'); | |
| 69 | + $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | |
| 70 | 70 | |
| 71 | 71 | $oReg =& KTi18nregistry::getSingleton(); |
| 72 | 72 | $aRegisteredLangs = $oReg->geti18nLanguages('knowledgeTree'); |
| ... | ... | @@ -76,61 +76,67 @@ class LoginPageDispatcher extends KTDispatcher { |
| 76 | 76 | $aRegisteredLanguageNames[$sLang] = $aLanguageNames[$sLang]; |
| 77 | 77 | } |
| 78 | 78 | $sLanguageSelect = $default->defaultLanguage; |
| 79 | - | |
| 80 | - $oTemplating =& KTTemplating::getSingleton(); | |
| 81 | - $oTemplate = $oTemplating->loadTemplate("ktcore/login"); | |
| 82 | - $aTemplateData = array( | |
| 79 | + | |
| 80 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 81 | + $oTemplate = $oTemplating->loadTemplate("ktcore/login"); | |
| 82 | + $aTemplateData = array( | |
| 83 | 83 | "context" => $this, |
| 84 | - 'cookietest' => $cookietest, | |
| 85 | - 'errorMessage' => $errorMessage, | |
| 86 | - 'redirect' => $redirect, | |
| 87 | - 'systemVersion' => $default->systemVersion, | |
| 88 | - 'versionName' => $default->versionName, | |
| 84 | + 'cookietest' => $cookietest, | |
| 85 | + 'errorMessage' => $errorMessage, | |
| 86 | + 'redirect' => $redirect, | |
| 87 | + 'systemVersion' => $default->systemVersion, | |
| 88 | + 'versionName' => $default->versionName, | |
| 89 | 89 | 'languages' => $aRegisteredLanguageNames, |
| 90 | 90 | 'selected_language' => $sLanguageSelect, |
| 91 | - ); | |
| 92 | - return $oTemplate->render($aTemplateData); | |
| 93 | - } | |
| 94 | - | |
| 95 | - function simpleRedirectToMain($errorMessage, $url, $params) { | |
| 96 | - $params[] = 'errorMessage='. urlencode($errorMessage); | |
| 97 | - $url .= '?' . join('&', $params); | |
| 98 | - redirect($url); | |
| 99 | - exit(0); | |
| 100 | - } | |
| 101 | - | |
| 102 | - function do_login() { | |
| 103 | - $this->check(); | |
| 104 | - global $default; | |
| 105 | - | |
| 106 | - $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | |
| 107 | - | |
| 108 | - $url = $_SERVER["PHP_SELF"]; | |
| 109 | - $queryParams = array(); | |
| 110 | - | |
| 111 | - if ($redirect !== null) { | |
| 112 | - $queryParams[] = 'redirect='. urlencode($redirect); | |
| 113 | - } | |
| 114 | - | |
| 115 | - | |
| 116 | - $cookieTest = KTUtil::arrayGet($_COOKIE, "CookieTestCookie", null); | |
| 117 | - $cookieVerify = KTUtil::arrayGet($_REQUEST, 'cookieverify', null); | |
| 118 | - | |
| 119 | - if (($cookieVerify === null) || ($cookieTest !== $cookieVerify)) { | |
| 120 | - $this->simpleRedirectToMain(_kt('You must have cookies enabled to use the document management system.'), $url, $params); | |
| 121 | - exit(0); | |
| 122 | - } | |
| 123 | - | |
| 124 | - $username = KTUtil::arrayGet($_REQUEST,'username'); | |
| 125 | - $password = KTUtil::arrayGet($_REQUEST,'password'); | |
| 126 | - | |
| 127 | - if (empty($username)) { | |
| 128 | - $this->simpleRedirectToMain(_kt('Please enter your username.'), $url, $params); | |
| 129 | - } | |
| 130 | - | |
| 131 | - if (empty($password)) { | |
| 132 | - $this->simpleRedirectToMain(_kt('Please enter your password.'), $url, $params); | |
| 133 | - } | |
| 91 | + ); | |
| 92 | + return $oTemplate->render($aTemplateData); | |
| 93 | + } | |
| 94 | + | |
| 95 | + function simpleRedirectToMain($errorMessage, $url, $params) { | |
| 96 | + $params[] = 'errorMessage='. urlencode($errorMessage); | |
| 97 | + $url .= '?' . join('&', $params); | |
| 98 | + redirect($url); | |
| 99 | + exit(0); | |
| 100 | + } | |
| 101 | + | |
| 102 | + function do_login() { | |
| 103 | + $this->check(); | |
| 104 | + global $default; | |
| 105 | + | |
| 106 | + $language = KTUtil::arrayGet($_REQUEST, 'language'); | |
| 107 | + if (empty($language)) { | |
| 108 | + $language = $default->defaultLanguage; | |
| 109 | + } | |
| 110 | + setcookie("kt_language", $language, 2147483647, '/'); | |
| 111 | + | |
| 112 | + $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); | |
| 113 | + | |
| 114 | + $url = $_SERVER["PHP_SELF"]; | |
| 115 | + $queryParams = array(); | |
| 116 | + | |
| 117 | + if ($redirect !== null) { | |
| 118 | + $queryParams[] = 'redirect='. urlencode($redirect); | |
| 119 | + } | |
| 120 | + | |
| 121 | + | |
| 122 | + $cookieTest = KTUtil::arrayGet($_COOKIE, "CookieTestCookie", null); | |
| 123 | + $cookieVerify = KTUtil::arrayGet($_REQUEST, 'cookieverify', null); | |
| 124 | + | |
| 125 | + if (($cookieVerify === null) || ($cookieTest !== $cookieVerify)) { | |
| 126 | + $this->simpleRedirectToMain(_kt('You must have cookies enabled to use the document management system.'), $url, $params); | |
| 127 | + exit(0); | |
| 128 | + } | |
| 129 | + | |
| 130 | + $username = KTUtil::arrayGet($_REQUEST,'username'); | |
| 131 | + $password = KTUtil::arrayGet($_REQUEST,'password'); | |
| 132 | + | |
| 133 | + if (empty($username)) { | |
| 134 | + $this->simpleRedirectToMain(_kt('Please enter your username.'), $url, $params); | |
| 135 | + } | |
| 136 | + | |
| 137 | + if (empty($password)) { | |
| 138 | + $this->simpleRedirectToMain(_kt('Please enter your password.'), $url, $params); | |
| 139 | + } | |
| 134 | 140 | |
| 135 | 141 | $oUser =& User::getByUsername($username); |
| 136 | 142 | if (PEAR::isError($oUser) || ($oUser === false)) { |
| ... | ... | @@ -154,11 +160,6 @@ class LoginPageDispatcher extends KTDispatcher { |
| 154 | 160 | |
| 155 | 161 | // DEPRECATED initialise page-level authorisation array |
| 156 | 162 | $_SESSION["pageAccess"] = NULL; |
| 157 | - $language = KTUtil::arrayGet($_REQUEST, 'language'); | |
| 158 | - if (empty($language)) { | |
| 159 | - $language = $default->defaultLanguage; | |
| 160 | - } | |
| 161 | - setcookie("kt_language", $language, 2147483647, '/'); | |
| 162 | 163 | |
| 163 | 164 | // check for a location to forward to |
| 164 | 165 | if ($redirect !== null) { |
| ... | ... | @@ -169,7 +170,7 @@ class LoginPageDispatcher extends KTDispatcher { |
| 169 | 170 | } |
| 170 | 171 | |
| 171 | 172 | exit(redirect($url)); |
| 172 | - } | |
| 173 | + } | |
| 173 | 174 | } |
| 174 | 175 | |
| 175 | 176 | ... | ... |