Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2622 from matrix-org/rav/db_access_for_auth_provi…
Browse files Browse the repository at this point in the history
…ders

Let auth providers get to the database
  • Loading branch information
dbkr authored Nov 2, 2017
2 parents 846a94f + 3e0aaad commit 04897c9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions synapse/handlers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ def __init__(self, hs, check_user_exists):
self.hs = hs

self._check_user_exists = check_user_exists
self._store = hs.get_datastore()

def get_qualified_user_id(self, username):
"""Qualify a user id, if necessary
Expand Down Expand Up @@ -863,3 +864,18 @@ def register(self, localpart):
"""
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)

0 comments on commit 04897c9

Please sign in to comment.