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

Commit b8b3e6a

Browse files
committed
Remove old register_mxid_from_3pid setting
1 parent 20d8e75 commit b8b3e6a

File tree

3 files changed

+0
-82
lines changed

3 files changed

+0
-82
lines changed

docs/sample_config.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,13 +1318,6 @@ oembed:
13181318
#
13191319
#disable_msisdn_registration: true
13201320

1321-
# Derive the user's matrix ID from a type of 3PID used when registering.
1322-
# This overrides any matrix ID the user proposes when calling /register
1323-
# The 3PID type should be present in registrations_require_3pid to avoid
1324-
# users failing to register if they don't specify the right kind of 3pid.
1325-
#
1326-
#register_mxid_from_3pid: email
1327-
13281321
# Uncomment to set the display name of new users to their email address,
13291322
# rather than using the default heuristic.
13301323
#

synapse/config/registration.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def read_config(self, config, **kwargs):
4444
"registration_requires_token", False
4545
)
4646
self.registration_shared_secret = config.get("registration_shared_secret")
47-
self.register_mxid_from_3pid = config.get("register_mxid_from_3pid")
4847
self.register_just_use_email_for_display_name = config.get(
4948
"register_just_use_email_for_display_name", False
5049
)
@@ -232,13 +231,6 @@ def generate_config_section(self, generate_secrets=False, **kwargs):
232231
#
233232
#disable_msisdn_registration: true
234233
235-
# Derive the user's matrix ID from a type of 3PID used when registering.
236-
# This overrides any matrix ID the user proposes when calling /register
237-
# The 3PID type should be present in registrations_require_3pid to avoid
238-
# users failing to register if they don't specify the right kind of 3pid.
239-
#
240-
#register_mxid_from_3pid: email
241-
242234
# Uncomment to set the display name of new users to their email address,
243235
# rather than using the default heuristic.
244236
#

synapse/rest/client/register.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -635,73 +635,6 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
635635
400, "%s is already in use" % medium, Codes.THREEPID_IN_USE
636636
)
637637

638-
if self.hs.config.registration.register_mxid_from_3pid:
639-
# override the desired_username based on the 3PID if any.
640-
# reset it first to avoid folks picking their own username.
641-
desired_username = None
642-
643-
# we should have an auth_result at this point if we're going to progress
644-
# to register the user (i.e. we haven't picked up a registered_user_id
645-
# from our session store), in which case get ready and gen the
646-
# desired_username
647-
if auth_result:
648-
if (
649-
self.hs.config.registration.register_mxid_from_3pid == "email"
650-
and LoginType.EMAIL_IDENTITY in auth_result
651-
):
652-
address = auth_result[LoginType.EMAIL_IDENTITY]["address"]
653-
desired_username = synapse.types.strip_invalid_mxid_characters(
654-
address.replace("@", "-").lower()
655-
)
656-
657-
# find a unique mxid for the account, suffixing numbers
658-
# if needed
659-
while True:
660-
try:
661-
await self.registration_handler.check_username(
662-
desired_username,
663-
guest_access_token=guest_access_token,
664-
assigned_user_id=registered_user_id,
665-
)
666-
# if we got this far we passed the check.
667-
break
668-
except SynapseError as e:
669-
if e.errcode == Codes.USER_IN_USE:
670-
m = re.match(r"^(.*?)(\d+)$", desired_username)
671-
if m:
672-
desired_username = m.group(1) + str(
673-
int(m.group(2)) + 1
674-
)
675-
else:
676-
desired_username += "1"
677-
else:
678-
# something else went wrong.
679-
break
680-
681-
if (
682-
self.hs.config.registration.register_just_use_email_for_display_name
683-
):
684-
desired_display_name = address
685-
else:
686-
# Custom mapping between email address and display name
687-
desired_display_name = _map_email_to_displayname(address)
688-
elif (
689-
self.hs.config.registration.register_mxid_from_3pid == "msisdn"
690-
and LoginType.MSISDN in auth_result
691-
):
692-
desired_username = auth_result[LoginType.MSISDN]["address"]
693-
else:
694-
raise SynapseError(
695-
400, "Cannot derive mxid from 3pid; no recognised 3pid"
696-
)
697-
698-
if desired_username is not None:
699-
await self.registration_handler.check_username(
700-
desired_username,
701-
guest_access_token=guest_access_token,
702-
assigned_user_id=registered_user_id,
703-
)
704-
705638
if registered_user_id is not None:
706639
logger.info(
707640
"Already registered user ID %r for this session", registered_user_id

0 commit comments

Comments
 (0)