account/views.py
def login(request, template_name='account/login.html',
          redirect_field_name=REDIRECT_FIELD_NAME,
          authentication_form=AuthenticationForm):
    """Displays the login form and handles the login action."""

    redirect_to = request.REQUEST.get(redirect_field_name, '')
    if request.method == "POST":
        form = authentication_form(data=request.POST)
        if form.is_valid():
            # Light security check -- make sure redirect_to isn't garbage.
            if not redirect_to or ' ' in redirect_to:
                redirect_to = '/website'
            
            # Heavier security check -- redirects to http://example.com should 
            # not be allowed, but things like /view/?param=http://example.com 
            # should be allowed. This regex checks if there is a '//' *before* a
            # question mark.
            elif '//' in redirect_to and re.match(r'[^\?]*//', redirect_to):
                    redirect_to = '/website/list'
            
            # Okay, security checks complete. Log the user in.
            auth_login(request, form.get_user())

            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()

            return HttpResponseRedirect(redirect_to)
    else:
        form = authentication_form(request)
    
    request.session.set_test_cookie()
    
    return render_to_response(template_name, {
        'form': form,
        redirect_field_name: redirect_to
    }, context_instance=RequestContext(request))
Displays the login form and handles the login action.
Displays the login form and handles the login action.
Displays the login form and handles the login action .
def login(request, template_name='account/login.html',
          redirect_field_name=REDIRECT_FIELD_NAME,
          authentication_form=AuthenticationForm):
    redirect_to = request.REQUEST.get(redirect_field_name, '')
    if request.method == "POST":
        form = authentication_form(data=request.POST)
        if form.is_valid():
            if not redirect_to or ' ' in redirect_to:
                redirect_to = '/website'
            elif '//' in redirect_to and re.match(r'[^\?]*//', redirect_to):
                    redirect_to = '/website/list'
            auth_login(request, form.get_user())
            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()
            return HttpResponseRedirect(redirect_to)
    else:
        form = authentication_form(request)
    request.session.set_test_cookie()
    return render_to_response(template_name, {
        'form': form,
        redirect_field_name: redirect_to
    }, context_instance=RequestContext(request))
def login ( request , template_name = 'account/login.html' , redirect_field_name = REDIRECT_FIELD_NAME , authentication_form = AuthenticationForm ) : redirect_to = request . REQUEST . get ( redirect_field_name , '' ) if request . method == "POST" : form = authentication_form ( data = request . POST ) if form . is_valid ( ) : if not redirect_to or ' ' in redirect_to : redirect_to = '/website' elif '//' in redirect_to and re . match ( r'[^\?]*//' , redirect_to ) : redirect_to = '/website/list' auth_login ( request , form . get_user ( ) ) if request . session . test_cookie_worked ( ) : request . session . delete_test_cookie ( ) return HttpResponseRedirect ( redirect_to ) else : form = authentication_form ( request ) request . session . set_test_cookie ( ) return render_to_response ( template_name , { 'form' : form , redirect_field_name : redirect_to } , context_instance = RequestContext ( request ) )
Displays the login form and handles the login action.
Displays the login form and handles the login action .
"""Displays the login form and handles the login action.""" # Light security check -- make sure redirect_to isn't garbage.
 # Heavier security check -- redirects to http://example.com should 
 # not be allowed, but things like /view/?param=http://example.com 
 # should be allowed. This regex checks if there is a '//' *before* a
 # question mark.
 # Okay, security checks complete. Log the user in.

request
template_name
redirect_field_name
authentication_form