Ticket #8061: temporary-session-key-login.diff
File temporary-session-key-login.diff, 1.8 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/views.py
17 17 "Displays the login form and handles the login action." 18 18 redirect_to = request.REQUEST.get(redirect_field_name, '') 19 19 if request.method == "POST": 20 form = AuthenticationForm( data=request.POST)20 form = AuthenticationForm(request, data=request.POST) 21 21 if form.is_valid(): 22 22 # Light security check -- make sure redirect_to isn't garbage. 23 23 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: … … 25 25 redirect_to = settings.LOGIN_REDIRECT_URL 26 26 from django.contrib.auth import login 27 27 login(request, form.get_user()) 28 if request.session.test_cookie_worked():29 request.session.delete_test_cookie()30 28 return HttpResponseRedirect(redirect_to) 31 29 else: 32 30 form = AuthenticationForm(request) 33 request.session.set_test_cookie()34 31 if Site._meta.installed: 35 32 current_site = Site.objects.get_current() 36 33 else: -
django/contrib/auth/forms.py
73 73 74 74 # TODO: determine whether this should move to its own method. 75 75 if self.request: 76 if not self.request.session. test_cookie_worked():76 if not self.request.session.accepts_cookies(): 77 77 raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")) 78 78 79 79 return self.cleaned_data