diff options
author | David Baker <dave@matrix.org> | 2016-10-14 13:56:53 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-10-14 13:56:53 +0100 |
commit | 62073992c523cc9b40c342c8443966cda7d8b5a4 (patch) | |
tree | a8aee970d8545f18f5bd92aebd40234ba1d715cc /synapse/storage/registration.py | |
parent | Merge pull request #1166 from matrix-org/rav/grandfather_broken_riot_signup (diff) | |
download | synapse-62073992c523cc9b40c342c8443966cda7d8b5a4.tar.xz |
Make password reset email field case insensitive
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r-- | synapse/storage/registration.py | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py index e404fa72de..a6aa64f9fb 100644 --- a/synapse/storage/registration.py +++ b/synapse/storage/registration.py @@ -458,17 +458,27 @@ class RegistrationStore(background_updates.BackgroundUpdateStore): @defer.inlineCallbacks def get_user_id_by_threepid(self, medium, address): - ret = yield self._simple_select_one( - "user_threepids", - { - "medium": medium, - "address": address - }, - ['user_id'], True, 'get_user_id_by_threepid' + def f(txn): + sql = ( + "SELECT user_id" + " FROM user_threepids" + " WHERE medium = ? AND LOWER(address) = LOWER(?)" + ) + txn.execute(sql, (medium, address)) + row = txn.fetchone() + if not row: + return None + if txn.rowcount > 1: + raise StoreError(500, "More than one row matched") + return { + "user_id": row[0] + } + + res = yield self.runInteraction( + "get_user_id_by_threepid", f ) - if ret: - defer.returnValue(ret['user_id']) - defer.returnValue(None) + + defer.returnValue(res) def user_delete_threepids(self, user_id): return self._simple_delete( |