Added case insensitive usernames.

This commit is contained in:
xevidos 2019-03-04 15:09:48 -05:00
parent dfed2269c9
commit e7471eb183
2 changed files with 5 additions and 5 deletions

View File

@ -347,7 +347,7 @@ class User {
public static function CleanUsername( $username ) { public static function CleanUsername( $username ) {
return preg_replace( '#[^A-Za-z0-9' . preg_quote( '-_@. ').']#', '', $username ); return strtolower( preg_replace( '#[^A-Za-z0-9' . preg_quote( '-_@. ').']#', '', $username ) );
} }
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////

View File

@ -32,7 +32,7 @@ if ($_GET['action']=='authenticate') {
die(formatJSEND("error", "Missing username or password")); die(formatJSEND("error", "Missing username or password"));
} }
$User->username = $_POST['username']; $User->username = User::CleanUsername( $_POST['username'] );
$User->password = $_POST['password']; $User->password = $_POST['password'];
// check if the asked languages exist and is registered in languages/code.php // check if the asked languages exist and is registered in languages/code.php
@ -68,7 +68,7 @@ if ($_GET['action']=='create') {
die(formatJSEND("error", "Missing username or password")); die(formatJSEND("error", "Missing username or password"));
} }
$User->username = User::CleanUsername($_POST['username']); $User->username = User::CleanUsername( $_POST['username'] );
$User->password = $_POST['password']; $User->password = $_POST['password'];
$User->Create(); $User->Create();
} }
@ -84,7 +84,7 @@ if ($_GET['action']=='delete') {
die(formatJSEND("error", "Missing username")); die(formatJSEND("error", "Missing username"));
} }
$User->username = $_GET['username']; $User->username = User::CleanUsername( $_GET['username'] );
$User->Delete(); $User->Delete();
} }
} }
@ -99,7 +99,7 @@ if ($_GET['action']=='password') {
} }
if (checkAccess() || $_POST['username'] == $_SESSION['user']) { if (checkAccess() || $_POST['username'] == $_SESSION['user']) {
$User->username = $_POST['username']; $User->username = User::CleanUsername( $_POST['username'] );
$User->password = $_POST['password']; $User->password = $_POST['password'];
$User->Password(); $User->Password();
} }