diff options
author | Matthew Hodgson <matthew@matrix.org> | 2018-05-03 17:52:46 +0100 |
---|---|---|
committer | Matthew Hodgson <matthew@matrix.org> | 2018-05-03 17:52:46 +0100 |
commit | 29921255618b882dfccb2645150a487c822ce8cc (patch) | |
tree | 6e90f83a3d09df1d2a9121466593a401b9b708e0 | |
parent | improve mxid & displayname selection for register_mxid_from_3pid (diff) | |
download | synapse-29921255618b882dfccb2645150a487c822ce8cc.tar.xz |
special case msisdns when deriving mxids from 3pids
-rw-r--r-- | synapse/rest/client/v2_alpha/register.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index 7dc0cea076..b5704a39d9 100644 --- a/synapse/rest/client/v2_alpha/register.py +++ b/synapse/rest/client/v2_alpha/register.py @@ -384,13 +384,8 @@ class RegisterRestServlet(RestServlet): # desired_username if auth_result: if ( - ( - self.hs.config.register_mxid_from_3pid == 'email' and - LoginType.EMAIL_IDENTITY in auth_result - ) or ( - self.hs.config.register_mxid_from_3pid == 'msisdn' and - LoginType.MSISDN in auth_result - ) + self.hs.config.register_mxid_from_3pid == 'email' and + LoginType.EMAIL_IDENTITY in auth_result ): address = auth_result[login_type]['address'] desired_username = types.strip_invalid_mxid_characters( @@ -428,6 +423,15 @@ class RegisterRestServlet(RestServlet): capwords(parts[0]) + " [" + capwords(parts[1].split(' ')[0]) + "]" ) + elif ( + self.hs.config.register_mxid_from_3pid == 'msisdn' and + LoginType.MSISDN in auth_result + ): + desired_username = auth_result[login_type]['address'] + else: + raise SynapseError( + 400, "Cannot derive mxid from 3pid; no recognised 3pid" + ) if desired_username is not None: yield self.registration_handler.check_username( |