mirror of https://github.com/zulip/zulip.git
auth: Redirect login to realm_redirect page instead of find_accounts.
This commit is contained in:
parent
788b98d041
commit
fc4b6d8f5e
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue