summary refs log tree commit diff
path: root/synapse/storage/registration.py
diff options
context:
space:
mode:
authorDaniel Wagner-Hall <daniel@matrix.org>2015-08-26 13:42:45 +0100
committerDaniel Wagner-Hall <daniel@matrix.org>2015-08-26 13:42:45 +0100
commitd3c0e488591386b7d24d23c6f6d3b237523fca89 (patch)
treea0d8c139b8ec3087421ff039902088980d4534f8 /synapse/storage/registration.py
parentMerge pull request #251 from matrix-org/removeadmin (diff)
downloadsynapse-d3c0e488591386b7d24d23c6f6d3b237523fca89.tar.xz
Merge erikj/user_dedup to develop
Diffstat (limited to 'synapse/storage/registration.py')
-rw-r--r--synapse/storage/registration.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index a2d0f7c4b1..c9ceb132ae 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -120,6 +120,20 @@ class RegistrationStore(SQLBaseStore):
             allow_none=True,
         )
 
+    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 lower(name) = lower(?)"
+            )
+            txn.execute(sql, (user_id,))
+            return dict(txn.fetchall())
+
+        return self.runInteraction("get_users_by_id_case_insensitive", f)
+
     @defer.inlineCallbacks
     def user_set_password_hash(self, user_id, password_hash):
         """