mirror of https://github.com/zulip/zulip.git
auth: Fix Google auth to not assume SUBDOMAINS_HOMEPAGE.
Previously, Google auth would redirect you back to the login page on this code path.
This commit is contained in:
parent
eb781de78d
commit
ab61fe5922
|
@ -1118,15 +1118,17 @@ class GoogleLoginTest(GoogleOAuthTest):
|
|||
self.assertEqual(result.status_code, 302)
|
||||
self.assertEqual(result.url, "http://testserver/")
|
||||
|
||||
def test_google_oauth2_wrong_subdomain(self):
|
||||
def test_google_oauth2_subdomains_homepage(self):
|
||||
# type: () -> None
|
||||
token_response = ResponseMock(200, {'access_token': "unique_token"})
|
||||
account_data = dict(name=dict(formatted="Full Name"),
|
||||
emails=[dict(type="account",
|
||||
value=self.example_email("hamlet"))])
|
||||
account_response = ResponseMock(200, account_data)
|
||||
with self.settings(REALMS_HAVE_SUBDOMAINS=True):
|
||||
with self.settings(REALMS_HAVE_SUBDOMAINS=True,
|
||||
SUBDOMAINS_HOMEPAGE=True):
|
||||
result = self.google_oauth2_test(token_response, account_response)
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertIn('subdomain=1', result.url)
|
||||
|
||||
def test_google_oauth2_400_token_response(self):
|
||||
|
|
|
@ -270,7 +270,8 @@ def send_oauth_request_to_google(request):
|
|||
mobile_flow_otp = request.GET.get('mobile_flow_otp', '0')
|
||||
|
||||
if settings.REALMS_HAVE_SUBDOMAINS:
|
||||
if not subdomain or not Realm.objects.filter(string_id=subdomain).exists():
|
||||
if ((settings.SUBDOMAINS_HOMEPAGE and subdomain == '') or
|
||||
not Realm.objects.filter(string_id=subdomain).exists()):
|
||||
return redirect_to_subdomain_login_url()
|
||||
|
||||
google_uri = 'https://accounts.google.com/o/oauth2/auth?'
|
||||
|
|
Loading…
Reference in New Issue