User names: removed case sensitivity

This commit is contained in:
Marcin Kurczewski 2013-11-21 22:29:38 +01:00
parent c8fb9c20c6
commit 909026ae0f
3 changed files with 6 additions and 6 deletions

View file

@ -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');

View file

@ -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();
}

View file

@ -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)