Ticket #10763: login_custom_form.diff
File login_custom_form.diff, 1.3 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/views.py
14 14 from django.contrib.auth.models import User 15 15 from django.views.decorators.cache import never_cache 16 16 17 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME ):17 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, form_object=AuthenticationForm): 18 18 "Displays the login form and handles the login action." 19 19 redirect_to = request.REQUEST.get(redirect_field_name, '') 20 20 if request.method == "POST": 21 form = AuthenticationForm(data=request.POST)21 form = form_object(data=request.POST) 22 22 if form.is_valid(): 23 23 # Light security check -- make sure redirect_to isn't garbage. 24 24 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: … … 29 29 request.session.delete_test_cookie() 30 30 return HttpResponseRedirect(redirect_to) 31 31 else: 32 form = AuthenticationForm(request)32 form = form_object(request) 33 33 request.session.set_test_cookie() 34 34 if Site._meta.installed: 35 35 current_site = Site.objects.get_current()