Skip to content

Commit

Permalink
Fixed #335 -- Admin login form now checks that cookies are enabled.
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@529 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Aug 17, 2005
1 parent 8acb6c8 commit b1d9682
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions django/middleware/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ def process_view(self, request, view_func, param_dict):
message = ""
return self.display_login_form(request, message)

# Check that the user accepts cookies.
if not request.session.test_cookie_worked():
message = "Looks like your browser isn't configured to accept cookies. Please enable cookies, reload this page, and try again."
return self.display_login_form(request, message)

# Check the password
username = request.POST.get('username', '')
try:
Expand Down Expand Up @@ -81,6 +86,7 @@ def process_view(self, request, view_func, param_dict):
return self.display_login_form(request, ERROR_MESSAGE)

def display_login_form(self, request, error_message=''):
request.session.set_test_cookie()
if request.POST and request.POST.has_key('post_data'):
# User has failed login BUT has previously saved 'post_data'
post_data = request.POST['post_data']
Expand Down

0 comments on commit b1d9682

Please sign in to comment.