registration: Clarify realm_creation conditionals in accounts_register.

No change in behavior.
This commit is contained in:
Rishi Gupta 2017-12-01 16:13:17 -08:00 committed by Greg Price
parent e545a681fc
commit d9ce33dcf0
1 changed files with 7 additions and 9 deletions

View File

@ -87,16 +87,15 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
return render_confirmation_key_error( return render_confirmation_key_error(
request, ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST)) request, ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST))
if realm and not email_allowed_for_realm(email, realm): if not email_allowed_for_realm(email, realm):
return render(request, "zerver/closed_realm.html", return render(request, "zerver/closed_realm.html",
context={"closed_domain_name": realm.name}) context={"closed_domain_name": realm.name})
if realm and realm.deactivated: if realm.deactivated:
# The user is trying to register for a deactivated realm. Advise them to # The user is trying to register for a deactivated realm. Advise them to
# contact support. # contact support.
return redirect_to_deactivation_notice() return redirect_to_deactivation_notice()
if not realm_creation:
try: try:
validate_email_for_realm(realm, email) validate_email_for_realm(realm, email)
except ValidationError: # nocoverage # We need to add a test for this. except ValidationError: # nocoverage # We need to add a test for this.
@ -245,7 +244,6 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
bulk_add_subscriptions([realm.signup_notifications_stream], [user_profile]) bulk_add_subscriptions([realm.signup_notifications_stream], [user_profile])
send_initial_realm_messages(realm) send_initial_realm_messages(realm)
if realm_creation:
# Because for realm creation, registration happens on the # Because for realm creation, registration happens on the
# root domain, we need to log them into the subdomain for # root domain, we need to log them into the subdomain for
# their new realm. # their new realm.