diff --git a/confirmation/models.py b/confirmation/models.py index c63607ba21..1f27dfa940 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -117,13 +117,17 @@ def create_confirmation_link( *, validity_in_minutes: Union[Optional[int], UnspecifiedValue] = UnspecifiedValue(), url_args: Mapping[str, str] = {}, - realm_creation: bool = False, + no_associated_realm_object: bool = False, ) -> str: # validity_in_minutes is an override for the default values which are # determined by the confirmation_type - its main purpose is for use # in tests which may want to have control over the exact expiration time. key = generate_key() - if realm_creation: + + # Some confirmation objects, like those for realm creation or those used + # for the self-hosted management flows, are not associated with a realm + # hosted by this Zulip server. + if no_associated_realm_object: realm = None else: assert not isinstance(obj, PreregistrationRealm) diff --git a/zerver/views/development/registration.py b/zerver/views/development/registration.py index 8136e43c8a..08a47ba4e5 100644 --- a/zerver/views/development/registration.py +++ b/zerver/views/development/registration.py @@ -71,7 +71,7 @@ def register_development_realm(request: HttpRequest) -> HttpResponse: email, realm_name, realm_subdomain, realm_type, realm_default_language ) activation_url = create_confirmation_link( - prereg_realm, Confirmation.REALM_CREATION, realm_creation=True + prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True ) key = activation_url.split("/")[-1] # Need to add test data to POST request as it doesn't originally contain the required parameters @@ -104,7 +104,7 @@ def register_demo_development_realm(request: HttpRequest) -> HttpResponse: email, realm_name, realm_subdomain, realm_type, realm_default_language ) activation_url = create_confirmation_link( - prereg_realm, Confirmation.REALM_CREATION, realm_creation=True + prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True ) key = activation_url.split("/")[-1] # Need to add test data to POST request as it doesn't originally contain the required parameters diff --git a/zerver/views/registration.py b/zerver/views/registration.py index ff3436e204..b8921bb140 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -753,7 +753,7 @@ def prepare_realm_activation_url( email, realm_name, string_id, org_type, default_language ) activation_url = create_confirmation_link( - prereg_realm, Confirmation.REALM_CREATION, realm_creation=True + prereg_realm, Confirmation.REALM_CREATION, no_associated_realm_object=True ) if settings.DEVELOPMENT: