Permalink
Browse files

Preserve case for userID during login

  • Loading branch information...
1 parent 701a923 commit 3ba39f77e27c5a2a8a59de8162e7060e08d68727 @mikeprimm mikeprimm committed Apr 4, 2012
Showing with 10 additions and 10 deletions.
  1. +3 −3 web/standalone/login.php
  2. +7 −7 web/standalone/register.php
View
6 web/standalone/login.php
@@ -22,8 +22,8 @@
hash_update($ctx, $pwdsalt);
hash_update($ctx, $password);
$hash = hash_final($ctx);
- $userid = strtolower($userid);
- if (strcasecmp($hash, $pwdhash[$userid]) == 0) {
+ $useridlc = strtolower($userid);
+ if (strcasecmp($hash, $pwdhash[$useridlc]) == 0) {
$_SESSION['userid'] = $userid;
$good = true;
}
@@ -43,7 +43,7 @@
$changed = false;
for($i=1; $i < $cnt; $i++) {
list($uid, $pc, $hsh) = split('=', rtrim($lines[$i]));
- if($uid == $userid) continue;
+ if($uid == $useridlc) continue;
if(array_key_exists($uid, $pendingreg)) {
$newlines[] = $uid . '=' . $pc . '=' . $hsh;
}
View
14 web/standalone/register.php
@@ -34,15 +34,15 @@
}
$good = false;
-$userid = strtolower($userid);
+$useridlc = strtolower($userid);
$_SESSION['userid'] = '-guest-';
$good = false;
-if(strcmp($userid, '-guest-')) {
- if(isset($pendingreg[$userid])) {
- if(!strcmp($passcode, $pendingreg[$userid])) {
+if(strcmp($useridlc, '-guest-')) {
+ if(isset($pendingreg[$useridlc])) {
+ if(!strcmp($passcode, $pendingreg[$useridlc])) {
$ctx = hash_init('sha256');
hash_update($ctx, $pwdsalt);
hash_update($ctx, $password);
@@ -56,13 +56,13 @@
$cnt = count($lines) - 1;
for($i=1; $i < $cnt; $i++) {
list($uid, $pc, $hsh) = split('=', rtrim($lines[$i]));
- if($uid == $userid) continue;
+ if($uid == $useridlc) continue;
if(array_key_exists($uid, $pendingreg)) {
$newlines[] = $uid . '=' . $pc . '=' . $hsh;
}
}
}
- $newlines[] = $userid . '=' . $passcode . '=' . $hash;
+ $newlines[] = $useridlc . '=' . $passcode . '=' . $hash;
$newlines[] = '*/ ?>';
file_put_contents('dynmap_reg.php', implode("\n", $newlines));
}
@@ -75,4 +75,4 @@
echo "{ \"result\": \"registerfailed\" }";
}
-?>
+?>

0 comments on commit 3ba39f7

Please sign in to comment.