Use lower instead of ilike to login users
authorChocobozzz <me@florianbigard.com>
Thu, 9 Jan 2020 13:00:34 +0000 (14:00 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 9 Jan 2020 13:00:34 +0000 (14:00 +0100)
scripts/generate-code-contributors.ts
server/models/account/user.ts

index 5c6620f7d22cbe64759d80a4c3791ea60a167043..f1922a20ef0125a98c9daa7b8f4fd77cf9a635d3 100755 (executable)
@@ -169,7 +169,7 @@ function getZanataContributors () {
 
 function getContributorsBlacklist () {
   return {
-    'Florian Bigard': true,
+    'Bigard Florian': true,
     'chocobozzz': true,
     'Rigel': true
   }
index 27262af422999ba1335e551133af8f59f8500b61..4c2c5e27862673eb74af492c9c3f33899d613b27 100644 (file)
@@ -1,4 +1,4 @@
-import { FindOptions, literal, Op, QueryTypes } from 'sequelize'
+import { FindOptions, literal, Op, QueryTypes, where, fn, col } from 'sequelize'
 import {
   AfterDestroy,
   AfterUpdate,
@@ -465,7 +465,11 @@ export class UserModel extends Model<UserModel> {
 
     const query = {
       where: {
-        [ Op.or ]: [ { username: { [ Op.iLike ]: username } }, { email } ]
+        [ Op.or ]: [
+          where(fn('lower', col('username')), fn('lower', username)),
+
+          { email }
+        ]
       }
     }