Ticket #8061: check-session-cookie.diff
File check-session-cookie.diff, 2.4 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 from django.conf import settings 77 if settings.SESSION_COOKIE_NAME not in self.request.COOKIES: 77 78 raise forms.ValidationError(_("Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in.")) 78 79 79 80 return self.cleaned_data -
django/contrib/sessions/backends/base.py
24 24 def __init__(self, session_key=None): 25 25 self._session_key = session_key 26 26 self.accessed = False 27 self.modified = False27 self.modified = (session_key is None) 28 28 29 29 def __contains__(self, key): 30 30 return key in self._session