diff --git a/zerver/forms.py b/zerver/forms.py index 75b44a7e8b..a07637fa98 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -171,14 +171,6 @@ class RealmCreationForm(forms.Form): del kwargs["domain"] super(RealmCreationForm, self).__init__(*args, **kwargs) - def clean_email(self): - # type: () -> text_type - data = self.cleaned_data['email'] - domain = split_email_to_domain(data) - if (get_realm(domain) is not None): - raise ValidationError(mark_safe(get_registration_string(domain))) - return data - class LoggingSetPasswordForm(SetPasswordForm): def save(self, commit=True): # type: (bool) -> UserProfile diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index b549de1270..bf227d6a7b 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -118,11 +118,15 @@ def accounts_register(request): # realm. domain = prereg_user.realm.domain realm = get_realm(domain) + elif realm_creation: + # For creating a new realm, there is no existing realm or domain + realm = None + domain = None elif settings.REALMS_HAVE_SUBDOMAINS: subdomain_realm = resolve_subdomain_to_realm(get_subdomain(request)) domain = resolve_email_to_domain(email) domain = subdomain_realm.domain if subdomain_realm else domain - if (not realm_creation and completely_open(domain)): + if completely_open(domain): # When subdomains are enabled and the user is registering into a # completely open subdomain without going through the correct url # for the completely open domains.