Ticket #8274: 8274.auth_forms.diff
File 8274.auth_forms.diff, 2.3 KB (added by , 16 years ago) |
---|
-
django/django/contrib/auth/views.py
16 16 from django.contrib.auth.models import User 17 17 import re 18 18 19 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME ):19 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm): 20 20 "Displays the login form and handles the login action." 21 21 redirect_to = request.REQUEST.get(redirect_field_name, '') 22 22 if request.method == "POST": 23 form = AuthenticationForm(data=request.POST)23 form = authentication_form(data=request.POST) 24 24 if form.is_valid(): 25 25 # Light security check -- make sure redirect_to isn't garbage. 26 26 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: … … 32 32 request.session.delete_test_cookie() 33 33 return HttpResponseRedirect(redirect_to) 34 34 else: 35 form = AuthenticationForm(request)35 form = authentication_form(request) 36 36 request.session.set_test_cookie() 37 37 if Site._meta.installed: 38 38 current_site = Site.objects.get_current() … … 135 135 return render_to_response(template_name, context_instance=RequestContext(request, 136 136 {'login_url': settings.LOGIN_URL})) 137 137 138 def password_change(request, template_name='registration/password_change_form.html' ):138 def password_change(request, template_name='registration/password_change_form.html', password_change_form=PasswordChangeForm): 139 139 if request.method == "POST": 140 form = PasswordChangeForm(request.user, request.POST)140 form = password_change_form(request.user, request.POST) 141 141 if form.is_valid(): 142 142 form.save() 143 143 return HttpResponseRedirect(reverse('django.contrib.auth.views.password_change_done')) 144 144 else: 145 form = PasswordChangeForm(request.user)145 form = password_change_form(request.user) 146 146 return render_to_response(template_name, { 147 147 'form': form, 148 148 }, context_instance=RequestContext(request))