diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 10ac11fad1..2cd3fd0e2c 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -950,7 +950,7 @@ class UserSignUpTest(ZulipTestCase): realm.invite_required = False realm.save() - result = self.client_post('/register/zulip.com/', {'email': email}) + result = self.client_post('/register/zulip/', {'email': email}) self.assertEqual(result.status_code, 302) self.assertTrue(result["Location"].endswith( diff --git a/zerver/views/__init__.py b/zerver/views/__init__.py index c1c42f5ee4..2015d7d459 100644 --- a/zerver/views/__init__.py +++ b/zerver/views/__init__.py @@ -298,26 +298,26 @@ def accounts_accept_terms(request): def create_preregistration_user(email, request, realm_creation=False): # type: (Text, HttpRequest, bool) -> HttpResponse - domain = request.session.pop('domain', None) - if domain is not None: - # domain was set in accounts_home_with_domain. + realm_str = request.session.pop('realm_str', None) + if realm_str is not None: + # realm_str was set in accounts_home_with_realm_str. # The user is trying to sign up for a completely open realm, # so create them a PreregistrationUser for that realm return PreregistrationUser.objects.create(email=email, - realm=get_realm(domain), + realm=get_realm_by_string_id(realm_str), realm_creation=realm_creation) return PreregistrationUser.objects.create(email=email, realm_creation=realm_creation) -def accounts_home_with_domain(request, domain): +def accounts_home_with_realm_str(request, realm_str): # type: (HttpRequest, str) -> HttpResponse - if not settings.REALMS_HAVE_SUBDOMAINS and completely_open(get_realm(domain)): + if not settings.REALMS_HAVE_SUBDOMAINS and completely_open(get_realm_by_string_id(realm_str)): # You can sign up for a completely open realm through a # special registration path that contains the domain in the # URL. We store this information in the session rather than # elsewhere because we don't have control over URL or form # data for folks registering through OpenID. - request.session["domain"] = domain + request.session["realm_str"] = realm_str return accounts_home(request) else: return HttpResponseRedirect(reverse('zerver.views.accounts_home')) @@ -383,8 +383,10 @@ def confirmation_key(request): def get_realm_from_request(request): # type: (HttpRequest) -> Realm if settings.REALMS_HAVE_SUBDOMAINS: - return get_realm_by_string_id(get_subdomain(request)) - return get_realm(request.session.get("domain")) + realm_str = get_subdomain(request) + else: + realm_str = request.session.get("realm_str") + return get_realm_by_string_id(realm_str) def accounts_home(request): # type: (HttpRequest) -> HttpResponse diff --git a/zproject/urls.py b/zproject/urls.py index 0aded5caa7..4af0f1eca2 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -115,7 +115,7 @@ i18n_urls = [ url(r'^login/$', zerver.views.auth.login_page, {'template_name': 'zerver/login.html'}, name='zerver.views.auth.login_page'), # A registration page that passes through the domain, for totally open realms. - url(r'^register/(?P\S+)/$', zerver.views.accounts_home_with_domain, name='zerver.views.accounts_home_with_domain'), + url(r'^register/(?P\S+)/$', zerver.views.accounts_home_with_realm_str, name='zerver.views.accounts_home_with_realm_str'), # API and integrations documentation url(r'^api/$', APIView.as_view(template_name='zerver/api.html')),