mirror of https://github.com/zulip/zulip.git
Create redirect_to_main_site function.
This function is used in OAuth logins so that we can redirect first to the root domain (e.g. zulipdev.com if subdomains are *.zulipdev.com).
This commit is contained in:
parent
7e8f8551de
commit
c7ec5a14ee
|
@ -14,7 +14,7 @@ from django.utils.translation import ugettext as _
|
||||||
from django.core import signing
|
from django.core import signing
|
||||||
from six import text_type
|
from six import text_type
|
||||||
from six.moves import urllib
|
from six.moves import urllib
|
||||||
from typing import Any, Dict, Optional, Tuple
|
from typing import Any, Dict, Optional, Tuple, Text
|
||||||
|
|
||||||
from confirmation.models import Confirmation
|
from confirmation.models import Confirmation
|
||||||
from zerver.forms import OurAuthenticationForm, WRONG_SUBDOMAIN_ERROR
|
from zerver.forms import OurAuthenticationForm, WRONG_SUBDOMAIN_ERROR
|
||||||
|
@ -160,10 +160,15 @@ def google_oauth2_csrf(request, value):
|
||||||
|
|
||||||
def start_google_oauth2(request):
|
def start_google_oauth2(request):
|
||||||
# type: (HttpRequest) -> HttpResponse
|
# type: (HttpRequest) -> HttpResponse
|
||||||
|
url = reverse('zerver.views.auth.send_oauth_request_to_google')
|
||||||
|
return redirect_to_main_site(request, url)
|
||||||
|
|
||||||
|
def redirect_to_main_site(request, url):
|
||||||
|
# type: (HttpRequest, Text) -> HttpResponse
|
||||||
main_site_uri = ''.join((
|
main_site_uri = ''.join((
|
||||||
settings.EXTERNAL_URI_SCHEME,
|
settings.EXTERNAL_URI_SCHEME,
|
||||||
settings.EXTERNAL_HOST,
|
settings.EXTERNAL_HOST,
|
||||||
reverse('zerver.views.auth.send_oauth_request_to_google'),
|
url,
|
||||||
))
|
))
|
||||||
params = {'subdomain': get_subdomain(request)}
|
params = {'subdomain': get_subdomain(request)}
|
||||||
return redirect(main_site_uri + '?' + urllib.parse.urlencode(params))
|
return redirect(main_site_uri + '?' + urllib.parse.urlencode(params))
|
||||||
|
|
Loading…
Reference in New Issue