Пример #1
0
    def test_get_embercli_host(self):
        """get_embercli_host returns ember-cli host"""
        with self.settings(MISAGO_EMBER_CLI_ORIGIN='http://somewhere:1234'):
            self.assertEqual(get_embercli_host(), 'somewhere:1234')

        with self.settings(MISAGO_EMBER_CLI_ORIGIN=''):
            self.assertIsNone(get_embercli_host())
Пример #2
0
def login(request):
    if request.method == 'POST':
        redirect_to = request.POST.get('redirect_to')
        if redirect_to:
            is_redirect_safe = is_safe_url(
                url=redirect_to, host=request.get_host())

            if not is_redirect_safe and is_ember_cli_request(request):
                is_redirect_safe = is_safe_url(
                    url=redirect_to, host=get_embercli_host())

            if is_redirect_safe:
                redirect_to_path = urlparse(redirect_to).path
                return redirect(redirect_to_path)

    return redirect(settings.LOGIN_REDIRECT_URL)
Пример #3
0
def login(request):
    if request.method == 'POST':
        redirect_to = request.POST.get('redirect_to')
        if redirect_to:
            is_redirect_safe = is_safe_url(url=redirect_to,
                                           host=request.get_host())

            if not is_redirect_safe and is_ember_cli_request(request):
                is_redirect_safe = is_safe_url(url=redirect_to,
                                               host=get_embercli_host())

            if is_redirect_safe:
                redirect_to_path = urlparse(redirect_to).path
                return redirect(redirect_to_path)

    return redirect(settings.LOGIN_REDIRECT_URL)
Пример #4
0
def site_address(request):
    if request.is_secure():
        site_protocol = 'https'
        address_template = 'https://%s'
    else:
        site_protocol = 'http'
        address_template = 'http://%s'

    if is_ember_cli_request(request):
        host = get_embercli_host()
    else:
        host = request.get_host()

    return {
        'SITE_PROTOCOL': site_protocol,
        'SITE_HOST': host,
        'SITE_ADDRESS': address_template % host
    }