Esempio n. 1
0
def form_post_success(state, msg='', redirect_url=None):
    """This function is meant to be called after a successful form POST.
    """
    request, response = state['request'], state['response']
    if request.headers.get(b'X-Requested-With') == b'XMLHttpRequest':
        raise response.json({"msg": msg} if msg else {})
    else:
        if not redirect_url:
            redirect_url = request.body.get('back_to') or request.path.raw
            redirect_url = response.sanitize_untrusted_url(redirect_url)
        redirect_url = _modify_query(redirect_url, 'success', b64encode_s(msg))
        response.redirect(redirect_url)
Esempio n. 2
0
def form_post_success(state, msg='', redirect_url=None):
    """This function is meant to be called after a successful form POST.
    """
    request, response = state['request'], state['response']
    if request.headers.get(b'X-Requested-With') == b'XMLHttpRequest':
        raise response.json({"msg": msg} if msg else {})
    else:
        if not redirect_url:
            redirect_url = request.body.get('back_to') or request.path.raw
            redirect_url = response.sanitize_untrusted_url(redirect_url)
        redirect_url = _modify_query(redirect_url, 'success', b64encode_s(msg))
        response.redirect(redirect_url)