mirror of
https://github.com/zulip/zulip.git
synced 2025-10-25 00:53:56 +00:00
registration: Improve error handling for source_realm_id.
This restores the previous behavior that we store None rather than throwing an exception in the presence of invalid input.
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user