summary refs log tree commit diff
path: root/synapse/handlers/register.py
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2019-03-28 15:48:07 +0000
committerGitHub <noreply@github.com>2019-03-28 15:48:07 +0000
commit7a91b9d81c8ef84ce3aff785f9e2fc0a8268df1f (patch)
tree05a2b0e07dda8663ef0c37c31895a094aa7254a5 /synapse/handlers/register.py
parentMerge pull request #4942 from matrix-org/erikj/fix_presence (diff)
downloadsynapse-7a91b9d81c8ef84ce3aff785f9e2fc0a8268df1f.tar.xz
Allow password providers to bind emails (#4947)
This PR allows password provider modules to bind email addresses when a user is registering and is motivated by matrix-org/matrix-synapse-ldap3#58
Diffstat (limited to 'synapse/handlers/register.py')
-rw-r--r--synapse/handlers/register.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/handlers/register.py b/synapse/handlers/register.py

index 58940e0320..a51d11a257 100644 --- a/synapse/handlers/register.py +++ b/synapse/handlers/register.py
@@ -153,6 +153,7 @@ class RegistrationHandler(BaseHandler): user_type=None, default_display_name=None, address=None, + bind_emails=[], ): """Registers a new client on the server. @@ -172,6 +173,7 @@ class RegistrationHandler(BaseHandler): default_display_name (unicode|None): if set, the new user's displayname will be set to this. Defaults to 'localpart'. address (str|None): the IP address used to perform the registration. + bind_emails (List[str]): list of emails to bind to this account. Returns: A tuple of (user_id, access_token). Raises: @@ -261,6 +263,21 @@ class RegistrationHandler(BaseHandler): if not self.hs.config.user_consent_at_registration: yield self._auto_join_rooms(user_id) + # Bind any specified emails to this account + current_time = self.hs.get_clock().time_msec() + for email in bind_emails: + # generate threepid dict + threepid_dict = { + "medium": "email", + "address": email, + "validated_at": current_time, + } + + # Bind email to new account + yield self._register_email_threepid( + user_id, threepid_dict, None, False, + ) + defer.returnValue((user_id, token)) @defer.inlineCallbacks