When logging in fetch user by user_id case insensitively, *unless* there are multiple case insensitive matches, in which case require the exact user_id

This commit is contained in:
Erik Johnston 2015-08-21 11:34:43 +01:00
parent aa3c9c7bd0
commit 42f12ad92f
3 changed files with 31 additions and 12 deletions

View file

@ -99,13 +99,16 @@ class RegistrationStore(SQLBaseStore):
)
def get_users_by_id_case_insensitive(self, user_id):
"""Gets users that match user_id case insensitively.
Returns a mapping of user_id -> password_hash.
"""
def f(txn):
sql = (
"SELECT name, password_hash FROM users"
" WHERE name = lower(?)"
" WHERE lower(name) = lower(?)"
)
txn.execute(sql, (user_id,))
return self.cursor_to_dict(txn)
return dict(txn.fetchall())
return self.runInteraction("get_users_by_id_case_insensitive", f)