summary refs log tree commit diff
path: root/synapse/handlers/register.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2020-04-24 11:16:05 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2020-04-24 11:16:05 +0100
commitef8e78c1e623db5df97c7401bc5af9960946915e (patch)
tree1e2c81d09848f304e989f6a1704f4140e2bbdd28 /synapse/handlers/register.py
parentFix some broken references (diff)
downloadsynapse-ef8e78c1e623db5df97c7401bc5af9960946915e.tar.xz
HACK: Bind email to identity server when using it for 3pid delegation
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r--synapse/handlers/register.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py
index b0a3725903..2325c6305c 100644
--- a/synapse/handlers/register.py
+++ b/synapse/handlers/register.py
@@ -619,7 +619,13 @@ class RegistrationHandler(BaseHandler):
         return (device_id, access_token)
 
     @defer.inlineCallbacks
-    def post_registration_actions(self, user_id, auth_result, access_token):
+    def post_registration_actions(
+        self,
+        user_id,
+        auth_result,
+        access_token,
+        bind_threepid_creds=None,
+    ):
         """A user has completed registration
 
         Args:
@@ -628,6 +634,10 @@ class RegistrationHandler(BaseHandler):
                 registered user.
             access_token (str|None): The access token of the newly logged in
                 device, or None if `inhibit_login` enabled.
+            bind_threepid_creds (dict|None): A dictionary containing validated
+                client_secret, sid, and possibly an id_access_token. If set,
+                will attempt to bind the matching 3pid to the identity server
+                specified by self.config.account_threepid_delegate_email
         """
         if self.hs.config.worker_app:
             yield self._post_registration_client(
@@ -646,6 +656,22 @@ class RegistrationHandler(BaseHandler):
 
             yield self.register_email_threepid(user_id, threepid, access_token)
 
+            if bind_threepid_creds:
+                # We've been requested to bind a threepid to an identity server
+                # This should only be set if we're using an identity server as an
+                # account_threepid_delegate for email
+                logger.debug(
+                    "Binding email to %s on id_server %s",
+                    user_id, self.hs.config.account_threepid_delegate_email,
+                )
+                yield self.identity_handler.bind_threepid(
+                    bind_threepid_creds["client_secret"],
+                    bind_threepid_creds["sid"],
+                    user_id,
+                    self.hs.config.account_threepid_delegate_email,
+                    bind_threepid_creds.get("id_access_token"),
+                )
+
         if auth_result and LoginType.MSISDN in auth_result:
             threepid = auth_result[LoginType.MSISDN]
             yield self._register_msisdn_threepid(user_id, threepid)