diff --git a/src/Controllers/AuthController.php b/src/Controllers/AuthController.php index 4f5edbc0..ddcf2adf 100644 --- a/src/Controllers/AuthController.php +++ b/src/Controllers/AuthController.php @@ -17,7 +17,7 @@ class AuthController $config = \Chibi\Registry::getConfig(); $context = \Chibi\Registry::getContext(); - $dbUser = R::findOne('user', 'name = ?', [$name]); + $dbUser = Model_User::locate($name, false); if ($dbUser === null) throw new SimpleException('Invalid username'); diff --git a/src/Models/Model_Post_QueryBuilder.php b/src/Models/Model_Post_QueryBuilder.php index 8fa0212b..fb11f624 100644 --- a/src/Models/Model_Post_QueryBuilder.php +++ b/src/Models/Model_Post_QueryBuilder.php @@ -197,7 +197,7 @@ class Model_Post_QueryBuilder implements AbstractQueryBuilder ->innerJoin('user') ->on('favoritee.user_id = user.id') ->where('post_id = post.id') - ->and('user.name = ?')->put($val) + ->and('LOWER(user.name) = LOWER(?)')->put($val) ->close(); } @@ -226,7 +226,7 @@ class Model_Post_QueryBuilder implements AbstractQueryBuilder ->innerJoin('user') ->on('commenter_id = user.id') ->where('post_id = post.id') - ->and('user.name = ?')->put($val) + ->and('LOWER(user.name) = LOWER(?)')->put($val) ->close(); } @@ -242,7 +242,7 @@ class Model_Post_QueryBuilder implements AbstractQueryBuilder ->open() ->select('user.id') ->from('user') - ->where('name = ?')->put($val) + ->where('LOWER(name) = LOWER(?)')->put($val) ->close(); } diff --git a/src/Models/Model_User.php b/src/Models/Model_User.php index cbb26098..59c47266 100644 --- a/src/Models/Model_User.php +++ b/src/Models/Model_User.php @@ -3,7 +3,7 @@ class Model_User extends AbstractModel { public static function locate($key, $throw = true) { - $user = R::findOne(self::getTableName(), 'name = ?', [$key]); + $user = R::findOne(self::getTableName(), 'LOWER(name) = LOWER(?)', [$key]); if ($user) return $user; @@ -97,7 +97,7 @@ class Model_User extends AbstractModel { $userName = trim($userName); - $dbUser = R::findOne(self::getTableName(), 'name = ?', [$userName]); + $dbUser = R::findOne(self::getTableName(), 'LOWER(name) = LOWER(?)', [$userName]); if ($dbUser !== null) { if (!$dbUser->email_confirmed and \Chibi\Registry::getConfig()->registration->needEmailForRegistering)