@@ -635,73 +635,6 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
635
635
400 , "%s is already in use" % medium , Codes .THREEPID_IN_USE
636
636
)
637
637
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
-
705
638
if registered_user_id is not None :
706
639
logger .info (
707
640
"Already registered user ID %r for this session" , registered_user_id
0 commit comments