Ticket #10342: r9897-login-form-override.patch
File r9897-login-form-override.patch, 1.7 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): 18 "Displays the login form and handles the login action." 17 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, form_class=AuthenticationForm): 18 """ 19 Displays the login form and handles the login action. 20 21 **Optional arguments** 22 23 ``template_name`` 24 A custom template to use. 25 26 ``redirect_field_name`` 27 A custom field name for redirect url. 28 29 ``form_class`` 30 The form class to use for login. 31 32 """ 33 19 34 redirect_to = request.REQUEST.get(redirect_field_name, '') 20 35 if request.method == "POST": 21 form = AuthenticationForm(data=request.POST)36 form = form_class(data=request.POST) 22 37 if form.is_valid(): 23 38 # Light security check -- make sure redirect_to isn't garbage. 24 39 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: … … 29 44 request.session.delete_test_cookie() 30 45 return HttpResponseRedirect(redirect_to) 31 46 else: 32 form = AuthenticationForm(request)47 form = form_class(request) 33 48 request.session.set_test_cookie() 34 49 if Site._meta.installed: 35 50 current_site = Site.objects.get_current()