diff --git a/synapse/rest/client/v2_alpha/register.py b/synapse/rest/client/v2_alpha/register.py index 7dc0cea07..b5704a39d 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(