summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-10-31 16:20:11 +0000
committerRichard van der Hoff <richard@matrix.org>2017-10-31 17:22:29 +0000
commit3e0aaad1903cb942920b06ba5eeb345d0256af19 (patch)
tree91099b24ef9ef619d64e0ac330579c6bc869ef17
parentMerge pull request #2610 from matrix-org/rav/schema_for_pw_providers (diff)
downloadsynapse-3e0aaad1903cb942920b06ba5eeb345d0256af19.tar.xz
Let auth providers get to the database
Somewhat open to abuse, but also somewhat unavoidable :/
-rw-r--r--synapse/handlers/auth.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/handlers/auth.py b/synapse/handlers/auth.py
index 93d8ac0e04..12c50f32f2 100644
--- a/synapse/handlers/auth.py
+++ b/synapse/handlers/auth.py
@@ -730,6 +730,7 @@ class _AccountHandler(object):
         self.hs = hs
 
         self._check_user_exists = check_user_exists
+        self._store = hs.get_datastore()
 
     def check_user_exists(self, user_id):
         """Check if user exissts.
@@ -747,3 +748,18 @@ class _AccountHandler(object):
         """
         reg = self.hs.get_handlers().registration_handler
         return reg.register(localpart=localpart)
+
+    def run_db_interaction(self, desc, func, *args, **kwargs):
+        """Run a function with a database connection
+
+        Args:
+            desc (str): description for the transaction, for metrics etc
+            func (func): function to be run. Passed a database cursor object
+                as well as *args and **kwargs
+            *args: positional args to be passed to func
+            **kwargs: named args to be passed to func
+
+        Returns:
+            Deferred[object]: result of func
+        """
+        return self._store.runInteraction(desc, func, *args, **kwargs)