Browse Source

Fix case sensitive for username in login form

A crutch to work not only in mysql.
Visman 4 năm trước cách đây
mục cha
commit
bd4b7a8f83
1 tập tin đã thay đổi với 14 bổ sung2 xóa
  1. 14 2
      app/Models/User/Load.php

+ 14 - 2
app/Models/User/Load.php

@@ -102,10 +102,22 @@ class Load extends Action
         $vars = [
             ':name' => $name,
         ];
-        $where = $caseInsencytive ? 'LOWER(u.username)=LOWER(?s:name)' : 'u.username=?s:name';
+        $where = 'u.username=?s:name';
         $query = $this->getSql($where);
 
-        return $this->returnUser($query, $vars);
+        $user = $this->returnUser($query, $vars);
+
+        if (
+            ! $user instanceof User
+            || (
+                false === $caseInsencytive
+                && $name !== $user->username
+            )
+        ) {
+            return null;
+        } else {
+            return $user;
+        }
     }
 
     /**