forked from MirrorHub/synapse
Remove bind_email and bind_msisdn (#5964)
Removes the `bind_email` and `bind_msisdn` parameters from the `/register` C/S API endpoint as per [MSC2140: Terms of Service for ISes and IMs](https://github.com/matrix-org/matrix-doc/pull/2140/files#diff-c03a26de5ac40fb532de19cb7fc2aaf7R107).
This commit is contained in:
parent
b09d443632
commit
b736c6cd3a
4 changed files with 10 additions and 64 deletions
1
changelog.d/5964.feature
Normal file
1
changelog.d/5964.feature
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Remove `bind_email` and `bind_msisdn` parameters from /register ala MSC2140.
|
|
@ -543,9 +543,7 @@ class RegistrationHandler(BaseHandler):
|
||||||
return (device_id, access_token)
|
return (device_id, access_token)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def post_registration_actions(
|
def post_registration_actions(self, user_id, auth_result, access_token):
|
||||||
self, user_id, auth_result, access_token, bind_email, bind_msisdn
|
|
||||||
):
|
|
||||||
"""A user has completed registration
|
"""A user has completed registration
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -554,18 +552,10 @@ class RegistrationHandler(BaseHandler):
|
||||||
registered user.
|
registered user.
|
||||||
access_token (str|None): The access token of the newly logged in
|
access_token (str|None): The access token of the newly logged in
|
||||||
device, or None if `inhibit_login` enabled.
|
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:
|
if self.hs.config.worker_app:
|
||||||
yield self._post_registration_client(
|
yield self._post_registration_client(
|
||||||
user_id=user_id,
|
user_id=user_id, auth_result=auth_result, access_token=access_token
|
||||||
auth_result=auth_result,
|
|
||||||
access_token=access_token,
|
|
||||||
bind_email=bind_email,
|
|
||||||
bind_msisdn=bind_msisdn,
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -578,13 +568,11 @@ class RegistrationHandler(BaseHandler):
|
||||||
):
|
):
|
||||||
yield self.store.upsert_monthly_active_user(user_id)
|
yield self.store.upsert_monthly_active_user(user_id)
|
||||||
|
|
||||||
yield self._register_email_threepid(
|
yield self._register_email_threepid(user_id, threepid, access_token)
|
||||||
user_id, threepid, access_token, bind_email
|
|
||||||
)
|
|
||||||
|
|
||||||
if auth_result and LoginType.MSISDN in auth_result:
|
if auth_result and LoginType.MSISDN in auth_result:
|
||||||
threepid = auth_result[LoginType.MSISDN]
|
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:
|
if auth_result and LoginType.TERMS in auth_result:
|
||||||
yield self._on_user_consented(user_id, self.hs.config.user_consent_version)
|
yield self._on_user_consented(user_id, self.hs.config.user_consent_version)
|
||||||
|
@ -603,14 +591,12 @@ class RegistrationHandler(BaseHandler):
|
||||||
yield self.post_consent_actions(user_id)
|
yield self.post_consent_actions(user_id)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@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
|
"""Add an email address as a 3pid identifier
|
||||||
|
|
||||||
Also adds an email pusher for the email address, if configured in the
|
Also adds an email pusher for the email address, if configured in the
|
||||||
HS config
|
HS config
|
||||||
|
|
||||||
Also optionally binds emails to the given user_id on the identity server
|
|
||||||
|
|
||||||
Must be called on master.
|
Must be called on master.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -618,8 +604,6 @@ class RegistrationHandler(BaseHandler):
|
||||||
threepid (object): m.login.email.identity auth response
|
threepid (object): m.login.email.identity auth response
|
||||||
token (str|None): access_token for the user, or None if not logged
|
token (str|None): access_token for the user, or None if not logged
|
||||||
in.
|
in.
|
||||||
bind_email (bool): true if the client requested the email to be
|
|
||||||
bound at the identity server
|
|
||||||
Returns:
|
Returns:
|
||||||
defer.Deferred:
|
defer.Deferred:
|
||||||
"""
|
"""
|
||||||
|
@ -661,28 +645,15 @@ class RegistrationHandler(BaseHandler):
|
||||||
data={},
|
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
|
@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
|
"""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.
|
Must be called on master.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
user_id (str): id of user
|
user_id (str): id of user
|
||||||
threepid (object): m.login.msisdn auth response
|
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:
|
Returns:
|
||||||
defer.Deferred:
|
defer.Deferred:
|
||||||
"""
|
"""
|
||||||
|
@ -698,12 +669,3 @@ class RegistrationHandler(BaseHandler):
|
||||||
yield self._auth_handler.add_threepid(
|
yield self._auth_handler.add_threepid(
|
||||||
user_id, threepid["medium"], threepid["address"], threepid["validated_at"]
|
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")
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ class ReplicationPostRegisterActionsServlet(ReplicationEndpoint):
|
||||||
self.registration_handler = hs.get_registration_handler()
|
self.registration_handler = hs.get_registration_handler()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _serialize_payload(user_id, auth_result, access_token, bind_email, bind_msisdn):
|
def _serialize_payload(user_id, auth_result, access_token):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
user_id (str): The user ID that consented
|
user_id (str): The user ID that consented
|
||||||
|
@ -114,17 +114,8 @@ class ReplicationPostRegisterActionsServlet(ReplicationEndpoint):
|
||||||
registered user.
|
registered user.
|
||||||
access_token (str|None): The access token of the newly logged in
|
access_token (str|None): The access token of the newly logged in
|
||||||
device, or None if `inhibit_login` enabled.
|
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 {
|
return {"auth_result": auth_result, "access_token": access_token}
|
||||||
"auth_result": auth_result,
|
|
||||||
"access_token": access_token,
|
|
||||||
"bind_email": bind_email,
|
|
||||||
"bind_msisdn": bind_msisdn,
|
|
||||||
}
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _handle_request(self, request, user_id):
|
def _handle_request(self, request, user_id):
|
||||||
|
@ -132,15 +123,9 @@ class ReplicationPostRegisterActionsServlet(ReplicationEndpoint):
|
||||||
|
|
||||||
auth_result = content["auth_result"]
|
auth_result = content["auth_result"]
|
||||||
access_token = content["access_token"]
|
access_token = content["access_token"]
|
||||||
bind_email = content["bind_email"]
|
|
||||||
bind_msisdn = content["bind_msisdn"]
|
|
||||||
|
|
||||||
yield self.registration_handler.post_registration_actions(
|
yield self.registration_handler.post_registration_actions(
|
||||||
user_id=user_id,
|
user_id=user_id, auth_result=auth_result, access_token=access_token
|
||||||
auth_result=auth_result,
|
|
||||||
access_token=access_token,
|
|
||||||
bind_email=bind_email,
|
|
||||||
bind_msisdn=bind_msisdn,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return 200, {}
|
return 200, {}
|
||||||
|
|
|
@ -481,8 +481,6 @@ class RegisterRestServlet(RestServlet):
|
||||||
user_id=registered_user_id,
|
user_id=registered_user_id,
|
||||||
auth_result=auth_result,
|
auth_result=auth_result,
|
||||||
access_token=return_dict.get("access_token"),
|
access_token=return_dict.get("access_token"),
|
||||||
bind_email=params.get("bind_email"),
|
|
||||||
bind_msisdn=params.get("bind_msisdn"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return 200, return_dict
|
return 200, return_dict
|
||||||
|
|
Loading…
Reference in a new issue