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

Remove bind_email and bind_msisdn #5964

Merged
merged 3 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5964.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `bind_email` and `bind_msisdn` parameters from /register ala MSC2140.
50 changes: 6 additions & 44 deletions synapse/handlers/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,7 @@ def register_device(self, user_id, device_id, initial_display_name, is_guest=Fal
return (device_id, access_token)

@defer.inlineCallbacks
def post_registration_actions(
self, user_id, auth_result, access_token, bind_email, bind_msisdn
):
def post_registration_actions(self, user_id, auth_result, access_token):
"""A user has completed registration

Args:
Expand All @@ -554,18 +552,10 @@ def post_registration_actions(
registered user.
access_token (str|None): The access token of the newly logged in
device, or None if `inhibit_login` enabled.
bind_email (bool): Whether to bind the email with the identity
server.
bind_msisdn (bool): Whether to bind the msisdn with the identity
server.
"""
if self.hs.config.worker_app:
yield self._post_registration_client(
user_id=user_id,
auth_result=auth_result,
access_token=access_token,
bind_email=bind_email,
bind_msisdn=bind_msisdn,
user_id=user_id, auth_result=auth_result, access_token=access_token
)
return

Expand All @@ -578,13 +568,11 @@ def post_registration_actions(
):
yield self.store.upsert_monthly_active_user(user_id)

yield self._register_email_threepid(
user_id, threepid, access_token, bind_email
)
yield self._register_email_threepid(user_id, threepid, access_token)

if auth_result and LoginType.MSISDN in auth_result:
threepid = auth_result[LoginType.MSISDN]
yield self._register_msisdn_threepid(user_id, threepid, bind_msisdn)
yield self._register_msisdn_threepid(user_id, threepid)

if auth_result and LoginType.TERMS in auth_result:
yield self._on_user_consented(user_id, self.hs.config.user_consent_version)
Expand All @@ -603,23 +591,19 @@ def _on_user_consented(self, user_id, consent_version):
yield self.post_consent_actions(user_id)

@defer.inlineCallbacks
def _register_email_threepid(self, user_id, threepid, token, bind_email):
def _register_email_threepid(self, user_id, threepid, token):
"""Add an email address as a 3pid identifier

Also adds an email pusher for the email address, if configured in the
HS config

Also optionally binds emails to the given user_id on the identity server

Must be called on master.

Args:
user_id (str): id of user
threepid (object): m.login.email.identity auth response
token (str|None): access_token for the user, or None if not logged
in.
bind_email (bool): true if the client requested the email to be
bound at the identity server
Returns:
defer.Deferred:
"""
Expand Down Expand Up @@ -661,28 +645,15 @@ def _register_email_threepid(self, user_id, threepid, token, bind_email):
data={},
)

if bind_email:
logger.info("bind_email specified: binding")
logger.debug("Binding emails %s to %s" % (threepid, user_id))
yield self.identity_handler.bind_threepid(
threepid["threepid_creds"], user_id
)
else:
logger.info("bind_email not specified: not binding email")

@defer.inlineCallbacks
def _register_msisdn_threepid(self, user_id, threepid, bind_msisdn):
def _register_msisdn_threepid(self, user_id, threepid):
"""Add a phone number as a 3pid identifier

Also optionally binds msisdn to the given user_id on the identity server

Must be called on master.

Args:
user_id (str): id of user
threepid (object): m.login.msisdn auth response
bind_msisdn (bool): true if the client requested the msisdn to be
bound at the identity server
Returns:
defer.Deferred:
"""
Expand All @@ -698,12 +669,3 @@ def _register_msisdn_threepid(self, user_id, threepid, bind_msisdn):
yield self._auth_handler.add_threepid(
user_id, threepid["medium"], threepid["address"], threepid["validated_at"]
)

if bind_msisdn:
logger.info("bind_msisdn specified: binding")
logger.debug("Binding msisdn %s to %s", threepid, user_id)
yield self.identity_handler.bind_threepid(
threepid["threepid_creds"], user_id
)
else:
logger.info("bind_msisdn not specified: not binding msisdn")
21 changes: 3 additions & 18 deletions synapse/replication/http/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,41 +106,26 @@ def __init__(self, hs):
self.registration_handler = hs.get_registration_handler()

@staticmethod
def _serialize_payload(user_id, auth_result, access_token, bind_email, bind_msisdn):
def _serialize_payload(user_id, auth_result, access_token):
"""
Args:
user_id (str): The user ID that consented
auth_result (dict): The authenticated credentials of the newly
registered user.
access_token (str|None): The access token of the newly logged in
device, or None if `inhibit_login` enabled.
bind_email (bool): Whether to bind the email with the identity
server
bind_msisdn (bool): Whether to bind the msisdn with the identity
server
"""
return {
"auth_result": auth_result,
"access_token": access_token,
"bind_email": bind_email,
"bind_msisdn": bind_msisdn,
}
return {"auth_result": auth_result, "access_token": access_token}

@defer.inlineCallbacks
def _handle_request(self, request, user_id):
content = parse_json_object_from_request(request)

auth_result = content["auth_result"]
access_token = content["access_token"]
bind_email = content["bind_email"]
bind_msisdn = content["bind_msisdn"]

yield self.registration_handler.post_registration_actions(
user_id=user_id,
auth_result=auth_result,
access_token=access_token,
bind_email=bind_email,
bind_msisdn=bind_msisdn,
user_id=user_id, auth_result=auth_result, access_token=access_token
)

return 200, {}
Expand Down
2 changes: 0 additions & 2 deletions synapse/rest/client/v2_alpha/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,6 @@ def on_POST(self, request):
user_id=registered_user_id,
auth_result=auth_result,
access_token=return_dict.get("access_token"),
bind_email=params.get("bind_email"),
bind_msisdn=params.get("bind_msisdn"),
)

return 200, return_dict
Expand Down