special case msisdns when deriving mxids from 3pids

This commit is contained in:
Matthew Hodgson 2018-05-03 17:52:46 +01:00
parent 32e4420a66
commit 2992125561

View file

@ -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(