Ejemplo n.º 1
0
def _post_login(request):
    user = authenticate(username=request.POST.get('username'),
                        password=request.POST.get('password'))
    # A traditional POST login will likely NOT create a 'Token', so lets do that now.
    if user:
        new_token = generate_token(user)
        _apply_token_to_session(request, new_token.token)
    auth_login(request, user)
Ejemplo n.º 2
0
def _mock_login(request):
    user = authenticate(username=None, request=request)
    auth_login(request, user)
    last_token = user.auth_tokens.last()
    if not last_token:
        last_token = generate_token(user)
    _apply_token_to_session(request, last_token.key)

    if request.session.get('redirect_to'):
        logger.debug("Found `redirect_to` in session... ")
        logger.debug("Redirecting to: %s" %
            (request.session.get('redirect_to'),))

        redirect_url = request.session.pop('redirect_to')
        return redirect(redirect_url)
    elif 'redirect_to' in request.GET:
        logger.debug("Found `redirect_to` in GET params... ")
        logger.debug("Redirecting to: %s" %
            (request.GET.get('redirect_to'),))

        redirect_url = request.GET.get('redirect_to')
        return redirect(redirect_url)
    return redirect('application')