diff --git a/.gitignore b/.gitignore index bb3ffc6..0f65e88 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ /database.mwb.bak /nbproject/private *.sync-conflict* -test* \ No newline at end of file +test* +/conf/ \ No newline at end of file diff --git a/index.php b/index.php index 21974b8..cfef2e6 100644 --- a/index.php +++ b/index.php @@ -50,9 +50,9 @@ if ($VARS['progress'] == "1") { default: if (!is_empty($error)) { $alert = $error; - break; + } else { + $alert = lang("login error", false); } - $alert = lang("login error", false); break; } if ($username_ok) { diff --git a/lib/login.php b/lib/login.php index 68654c3..e17d67f 100644 --- a/lib/login.php +++ b/lib/login.php @@ -127,19 +127,19 @@ function change_password($old, $new, $new2, &$error) { function account_location($username) { global $database; $username = strtolower($username); - $user_exists = user_exists_local($username); - if (!$user_exists && !LDAP_ENABLED) { - return false; + $user_exists_local = user_exists_local($username); + if (!$user_exists_local && !LDAP_ENABLED) { + return "NONE"; } - if ($user_exists) { + if ($user_exists_local) { $userinfo = $database->select('accounts', ['password'], ['username' => $username])[0]; // if password empty, it's an LDAP user - if (is_empty($userinfo['password']) && LDAP_ENABLED) { + if (!is_empty($userinfo['password'])) { + return "LOCAL"; + } else if (is_empty($userinfo['password']) && LDAP_ENABLED) { return "LDAP"; - } else if (is_empty($userinfo['password']) && !LDAP_ENABLED) { - return "NONE"; } else { - return "LOCAL"; + return "NONE"; } } else { if (user_exists_ldap($username)) { @@ -161,7 +161,7 @@ function authenticate_user($username, $password, &$errormsg = null, &$errorcode global $ldap; $username = strtolower($username); if (is_empty($username) || is_empty($password)) { - return false; + return "NONE"; } $loc = account_location($username, $password); switch ($loc) { @@ -200,7 +200,7 @@ function user_exists($username) { function user_exists_local($username) { global $database; $username = strtolower($username); - return $database->has('accounts', ['username' => $username, "LIMIT" => QUERY_LIMIT]); + return $database->has('accounts', ['username' => $username]) === TRUE; } /**