Ticket #14405: patch-14405.4.diff

File patch-14405.4.diff, 1.7 KB (added by Chris Tandiono, 14 years ago)
  • views.py

     
    2727
    2828    redirect_to = request.REQUEST.get(redirect_field_name, '')
    2929
    30     if request.method == "POST":
    31         form = authentication_form(data=request.POST)
    32         if form.is_valid():
     30    if request.method == "POST" or request.user.is_authenticated():
     31        if request.method == "POST" and not request.user.is_authenticated():
     32            form = authentication_form(data=request.POST)
     33        if request.user.is_authenticated() or form.is_valid():
    3334            # Light security check -- make sure redirect_to isn't garbage.
    3435            if not redirect_to or ' ' in redirect_to:
    3536                redirect_to = settings.LOGIN_REDIRECT_URL
     
    3940            # should be allowed. This regex checks if there is a '//' *before* a
    4041            # question mark.
    4142            elif '//' in redirect_to and re.match(r'[^\?]*//', redirect_to):
    42                     redirect_to = settings.LOGIN_REDIRECT_URL
    43 
     43                redirect_to = settings.LOGIN_REDIRECT_URL
     44           
    4445            # Okay, security checks complete. Log the user in.
    45             auth_login(request, form.get_user())
     46            if request.method == "POST" and not request.user.is_authenticated():
     47                auth_login(request, form.get_user())
     48                if request.session.test_cookie_worked():
     49                    request.session.delete_test_cookie()
    4650
    47             if request.session.test_cookie_worked():
    48                 request.session.delete_test_cookie()
    49 
    5051            return HttpResponseRedirect(redirect_to)
    5152
    5253    else:
Back to Top