Skip to content
Snippets Groups Projects
Unverified Commit 04897c9d authored by David Baker's avatar David Baker Committed by GitHub
Browse files

Merge pull request #2622 from matrix-org/rav/db_access_for_auth_providers

Let auth providers get to the database
parents 846a94fb 3e0aaad1
No related branches found
No related tags found
No related merge requests found
...@@ -826,6 +826,7 @@ class _AccountHandler(object): ...@@ -826,6 +826,7 @@ class _AccountHandler(object):
self.hs = hs self.hs = hs
self._check_user_exists = check_user_exists self._check_user_exists = check_user_exists
self._store = hs.get_datastore()
def get_qualified_user_id(self, username): def get_qualified_user_id(self, username):
"""Qualify a user id, if necessary """Qualify a user id, if necessary
...@@ -863,3 +864,18 @@ class _AccountHandler(object): ...@@ -863,3 +864,18 @@ class _AccountHandler(object):
""" """
reg = self.hs.get_handlers().registration_handler reg = self.hs.get_handlers().registration_handler
return reg.register(localpart=localpart) 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment