diff options
author | Erik Johnston <erik@matrix.org> | 2015-08-21 10:57:47 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-08-21 10:57:47 +0100 |
commit | aa3c9c7bd0736bca1b3626c87535192b89431583 (patch) | |
tree | 284705c17078df9e83fba52ca87743bfacfce3a6 /synapse/storage | |
parent | Fix bug where we didn't correctly serialize the redacted_because key over fed... (diff) | |
download | synapse-aa3c9c7bd0736bca1b3626c87535192b89431583.tar.xz |
Don't allow people to register user ids which only differ by case to an existing one
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/registration.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py index bf803f2c6e..25adecaf6d 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py @@ -98,6 +98,17 @@ class RegistrationStore(SQLBaseStore): allow_none=True, ) + def get_users_by_id_case_insensitive(self, user_id): + def f(txn): + sql = ( + "SELECT name, password_hash FROM users" + " WHERE name = lower(?)" + ) + txn.execute(sql, (user_id,)) + return self.cursor_to_dict(txn) + + return self.runInteraction("get_users_by_id_case_insensitive", f) + @defer.inlineCallbacks def user_set_password_hash(self, user_id, password_hash): """ |