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

Commit 3e0aaad

Browse files
committed
Let auth providers get to the database
Somewhat open to abuse, but also somewhat unavoidable :/
1 parent a72e4e3 commit 3e0aaad

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

synapse/handlers/auth.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ def __init__(self, hs, check_user_exists):
730730
self.hs = hs
731731

732732
self._check_user_exists = check_user_exists
733+
self._store = hs.get_datastore()
733734

734735
def check_user_exists(self, user_id):
735736
"""Check if user exissts.
@@ -747,3 +748,18 @@ def register(self, localpart):
747748
"""
748749
reg = self.hs.get_handlers().registration_handler
749750
return reg.register(localpart=localpart)
751+
752+
def run_db_interaction(self, desc, func, *args, **kwargs):
753+
"""Run a function with a database connection
754+
755+
Args:
756+
desc (str): description for the transaction, for metrics etc
757+
func (func): function to be run. Passed a database cursor object
758+
as well as *args and **kwargs
759+
*args: positional args to be passed to func
760+
**kwargs: named args to be passed to func
761+
762+
Returns:
763+
Deferred[object]: result of func
764+
"""
765+
return self._store.runInteraction(desc, func, *args, **kwargs)

0 commit comments

Comments
 (0)