Skip to content

Commit c152e8e

Browse files
author
danh
committed
Usernames no longer case sensitive
git-svn-id: http://svn.resourcespace.org/svn/resourcespace@3779 c08608d7-6e46-0410-86ca-f2a6f1370df5
1 parent c86cecc commit c152e8e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/login_functions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function perform_login()
3333
$session_hash=md5($password_hash . $username . $password . date("Y-m-d"));
3434
if ($enable_remote_apis){$session_hash=md5($password_hash.$username.date("Y-m-d"));} // no longer necessary to omit password in this hash for api support
3535

36-
$valid=sql_query("select ref,usergroup from user where username='".escape_check($username)."' and (password='".escape_check($password)."' or password='".escape_check($password_hash)."')");
36+
$valid=sql_query("select ref,usergroup from user where lower(username)='".escape_check($username)."' and (password='".escape_check($password)."' or password='".escape_check($password_hash)."')");
3737

3838
# Prepare result array
3939
$result=array();
@@ -54,7 +54,7 @@ function perform_login()
5454
$result['password_hash']=$password_hash;
5555

5656
# Update the user record. Set the password hash again in case a plain text password was provided.
57-
sql_query("update user set password='".escape_check($password_hash)."',session='".escape_check($session_hash)."',last_active=now(),login_tries=0,lang='".getvalescaped("language","")."' where username='".escape_check($username)."' and (password='".escape_check($password)."' or password='".escape_check($password_hash)."')");
57+
sql_query("update user set password='".escape_check($password_hash)."',session='".escape_check($session_hash)."',last_active=now(),login_tries=0,lang='".getvalescaped("language","")."' where lower(username)='".escape_check($username)."' and (password='".escape_check($password)."' or password='".escape_check($password_hash)."')");
5858

5959
# Log this
6060
$userref=$valid[0]["ref"];

login.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# Process the submitted login
4242
elseif (array_key_exists("username",$_POST) && getval("langupdate","")=="")
4343
{
44-
$username=getvalescaped("username","");
44+
$username=strtolower(getvalescaped("username",""));
4545
$password=getvalescaped("password","");
4646

4747
$result=perform_login();

0 commit comments

Comments
 (0)