summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-08-21 11:34:43 +0100
committerErik Johnston <erik@matrix.org>2015-08-21 11:38:44 +0100
commit42f12ad92f5bc372569f15ffc81e9cf8146d2ac6 (patch)
tree5b9e4d484c7a3e0110c8fafeed2428fb00a20b8b /synapse/storage
parentDon't allow people to register user ids which only differ by case to an exist... (diff)
downloadsynapse-42f12ad92f5bc372569f15ffc81e9cf8146d2ac6.tar.xz
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
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/registration.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py

index 25adecaf6d..586628579d 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py
@@ -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)