From: paca70 Date: Thu, 24 Apr 2003 20:06:40 +0000 (+0000) Subject: Conver usernames to lowercase for internal use. This prevent duplicate users X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1e22bc9c04eefece0ddc3d2267145d457cdfac79;p=moodle.git Conver usernames to lowercase for internal use. This prevent duplicate users when using external authentication and posgresql. --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 6e683b18fc..bfc626f1cb 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -489,7 +489,8 @@ function get_moodle_cookie() { function create_user_record($username, $password) { /// Creates a bare-bones user record global $REMOTE_ADDR, $CFG; - + //just in case check text case + $username = trim(moodle_strtolower($username)); if (function_exists(auth_get_userinfo)) { if ($newinfo = auth_get_userinfo($username)) { foreach ($newinfo as $key => $value){ diff --git a/login/index.php b/login/index.php index c64c53b5fb..1718696a1e 100644 --- a/login/index.php +++ b/login/index.php @@ -21,8 +21,8 @@ if ($frm = data_submitted()) { + $frm->username = trim(moodle_strtolower($frm->username)); $user = authenticate_user_login($frm->username, $frm->password); - update_login_count(); if ($user) { diff --git a/login/signup.php b/login/signup.php index 8bab6c76c5..16ecc068c0 100644 --- a/login/signup.php +++ b/login/signup.php @@ -6,7 +6,7 @@ if ($user = data_submitted()) { validate_form($user, $err); - + $user->username= trim(moodle_strtolower($user->username)); if (count((array)$err) == 0) { $plainpass = $user->password; $user->password = md5($user->password); @@ -74,16 +74,17 @@ function validate_form($user, &$err) { global $CFG; - if (empty($user->username)) + if (empty($user->username)){ $err->username = get_string("missingusername"); - - else if (record_exists("user", "username", $user->username)) - $err->username = get_string("usernameexists"); - - else { - $string = eregi_replace("[^([:alnum:])]", "", $user->username); - if (strcmp($user->username, $string)) + }else{ + $user->username = trim(moodle_strtolower($user->username)); + if (record_exists("user", "username", $user->username)){ + $err->username = get_string("usernameexists"); + }else { + $string = eregi_replace("[^([:alnum:])]", "", $user->username); + if (strcmp($user->username, $string)) $err->username = get_string("alphanumerical"); + } } if (isset($CFG->auth_user_create) and $CFG->auth_user_create==1 and function_exists('auth_user_exists') ){ diff --git a/user/edit.php b/user/edit.php index 71371fb7f2..53efbecf98 100644 --- a/user/edit.php +++ b/user/edit.php @@ -45,7 +45,7 @@ if ($usernew = data_submitted()) { $usernew->firstname = strip_tags($usernew->firstname); $usernew->lastname = strip_tags($usernew->lastname); - + $usernew->username = trim(moodle_strtolower($usernew->username)); if (empty($_FILES['imagefile'])) { $_FILES['imagefile'] = NULL; // To avoid using uninitialised variable later }