mirror of https://github.com/zulip/zulip.git
registration: Remove redundant code.
Since we have updated the registration code to use PreregistrationRealm objects for realm creation in previous commits, some of the code has become redundant and this commit removes it. We remove the following code - - The modification to PreregistrationUser objects in process_new_human_user can now be done unconditionally because prereg_user is passed only during user creation and not realm creation. And we anyway do not expect any PreregistrationUser objects inside the realm during the creation. - There is no need of "realm_creation" parameter in create_preregistration_user function, since we now use create_preregistration_realm during realm creation. Fixes part of #24307.
This commit is contained in:
parent
cf8d8db132
commit
00ffa3e870
|
@ -228,10 +228,6 @@ def process_new_human_user(
|
|||
prereg_user.created_user = user_profile
|
||||
prereg_user.save(update_fields=["status", "created_user"])
|
||||
|
||||
# In the special case of realm creation, there can be no additional PreregistrationUser
|
||||
# for us to want to modify - because other realm_creation PreregistrationUsers should be
|
||||
# left usable for creating different realms.
|
||||
if not realm_creation:
|
||||
# Mark any other PreregistrationUsers in the realm that are STATUS_USED as
|
||||
# inactive so we can keep track of the PreregistrationUser we
|
||||
# actually used for analytics.
|
||||
|
|
|
@ -118,18 +118,13 @@ def get_safe_redirect_to(url: str, redirect_host: str) -> str:
|
|||
def create_preregistration_user(
|
||||
email: str,
|
||||
realm: Optional[Realm],
|
||||
realm_creation: bool = False,
|
||||
password_required: bool = True,
|
||||
full_name: Optional[str] = None,
|
||||
full_name_validated: bool = False,
|
||||
multiuse_invite: Optional[MultiuseInvite] = None,
|
||||
) -> PreregistrationUser:
|
||||
assert not (realm_creation and realm is not None)
|
||||
assert not (realm is None and not realm_creation)
|
||||
|
||||
return PreregistrationUser.objects.create(
|
||||
email=email,
|
||||
realm_creation=realm_creation,
|
||||
password_required=password_required,
|
||||
realm=realm,
|
||||
full_name=full_name,
|
||||
|
|
|
@ -49,9 +49,7 @@ def register_development_user(request: HttpRequest) -> HttpResponse:
|
|||
count = UserProfile.objects.count()
|
||||
name = f"user-{count}"
|
||||
email = f"{name}@zulip.com"
|
||||
prereg = create_preregistration_user(
|
||||
email, realm, realm_creation=False, password_required=False
|
||||
)
|
||||
prereg = create_preregistration_user(email, realm, password_required=False)
|
||||
activation_url = create_confirmation_link(prereg, Confirmation.USER_REGISTRATION)
|
||||
key = activation_url.split("/")[-1]
|
||||
# Need to add test data to POST request as it doesn't originally contain the required parameters
|
||||
|
|
Loading…
Reference in New Issue