From fc4b6d8f5ed3a48ec746b59bc0c2308d4eb003af Mon Sep 17 00:00:00 2001 From: Vishnu Ks Date: Sat, 25 Aug 2018 19:51:59 +0530 Subject: [PATCH] auth: Redirect login to realm_redirect page instead of find_accounts. --- zerver/tests/test_signup.py | 18 +++++++++++++++--- zerver/views/auth.py | 4 +++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/zerver/tests/test_signup.py b/zerver/tests/test_signup.py index 9ff0d26b16..6502d39602 100644 --- a/zerver/tests/test_signup.py +++ b/zerver/tests/test_signup.py @@ -2919,7 +2919,11 @@ class TestLoginPage(ZulipTestCase): with self.settings(ROOT_DOMAIN_LANDING_PAGE=True): result = self.client_get("/en/login/") self.assertEqual(result.status_code, 302) - self.assertEqual(result.url, '/accounts/find/') + self.assertEqual(result.url, '/accounts/go/') + + result = self.client_get("/en/login/?next=/upgrade/") + self.assertEqual(result.status_code, 302) + self.assertEqual(result.url, '/accounts/go/?next=%2Fupgrade%2F') @patch('django.http.HttpRequest.get_host') def test_login_page_redirects_for_root_domain(self, mock_get_host: MagicMock) -> None: @@ -2927,7 +2931,11 @@ class TestLoginPage(ZulipTestCase): with self.settings(ROOT_DOMAIN_LANDING_PAGE=True): result = self.client_get("/en/login/") self.assertEqual(result.status_code, 302) - self.assertEqual(result.url, '/accounts/find/') + self.assertEqual(result.url, '/accounts/go/') + + result = self.client_get("/en/login/?next=/upgrade/") + self.assertEqual(result.status_code, 302) + self.assertEqual(result.url, '/accounts/go/?next=%2Fupgrade%2F') mock_get_host.return_value = 'www.testserver.com' with self.settings(ROOT_DOMAIN_LANDING_PAGE=True, @@ -2935,7 +2943,11 @@ class TestLoginPage(ZulipTestCase): ROOT_SUBDOMAIN_ALIASES=['test']): result = self.client_get("/en/login/") self.assertEqual(result.status_code, 302) - self.assertEqual(result.url, '/accounts/find/') + self.assertEqual(result.url, '/accounts/go/') + + result = self.client_get("/en/login/?next=/upgrade/") + self.assertEqual(result.status_code, 302) + self.assertEqual(result.url, '/accounts/go/?next=%2Fupgrade%2F') @patch('django.http.HttpRequest.get_host') def test_login_page_works_without_subdomains(self, mock_get_host: MagicMock) -> None: diff --git a/zerver/views/auth.py b/zerver/views/auth.py index d647b5d9dc..eae0fc91bd 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -608,7 +608,9 @@ def login_page(request: HttpRequest, **kwargs: Any) -> HttpResponse: elif request.user.is_authenticated: return HttpResponseRedirect(request.user.realm.uri) if is_subdomain_root_or_alias(request) and settings.ROOT_DOMAIN_LANDING_PAGE: - redirect_url = reverse('zerver.views.registration.find_account') + redirect_url = reverse('zerver.views.registration.realm_redirect') + if request.method == "GET" and request.GET: + redirect_url = "{}?{}".format(redirect_url, request.GET.urlencode()) return HttpResponseRedirect(redirect_url) realm = get_realm_from_request(request)