Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
registration: Improve error handling for source_realm_id.
Tim Abbott97b08b77dfb7
diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.pyindex 10edf60b63e..5457d3ecebb 100644--- a/zerver/tests/test_signup.py+++ b/zerver/tests/test_signup.py@@ -3748,6 +3748,7 @@ class UserSignUpTest(InviteUserBase):result = self.submit_reg_form_for_user(email,password,+ # Subdomain is already used, by construction.realm_subdomain=realm.string_id,realm_name=realm_name,source_realm_id=str(realm.id),diff --git a/zerver/views/registration.py b/zerver/views/registration.pyindex a973be0d3d9..62e9ba626a7 100644--- a/zerver/views/registration.py+++ b/zerver/views/registration.py@@ -311,10 +311,15 @@ def accounts_register(request: HttpRequest) -> HttpResponse:if "timezone" in request.POST and request.POST["timezone"] in pytz.all_timezones_set:timezone = request.POST["timezone"]- if "source_realm_id" in request.POST and request.POST["source_realm_id"] != "":- source_profile: Optional[UserProfile] = get_source_profile(- email, int(request.POST["source_realm_id"])- )+ if "source_realm_id" in request.POST:+ # Non-integer realm_id values like "string" are treated+ # like the "Do not import" value of "".+ try:+ source_realm_id = int(request.POST["source_realm_id"])+ except ValueError:+ source_profile: Optional[UserProfile] = None+ else:+ source_profile = get_source_profile(email, source_realm_id)else:source_profile = None