Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1234 -- Fixed admin problem with login status getting out of s…

…ync with multiple windows/tabs. Thanks, oggie rob

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2010 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d5a5f0f79007fdb2302cf86d2bb97739964f0a03 1 parent c4ab08a
Adrian Holovaty authored January 16, 2006
8  django/contrib/admin/views/decorators.py
@@ -3,7 +3,7 @@
3 3
 from django.models.auth import users
4 4
 from django.utils import httpwrappers
5 5
 from django.utils.translation import gettext_lazy
6  
-import base64, md5
  6
+import base64, datetime, md5
7 7
 import cPickle as pickle
8 8
 
9 9
 ERROR_MESSAGE = gettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.")
@@ -47,6 +47,10 @@ def staff_member_required(view_func):
47 47
     def _checklogin(request, *args, **kwargs):
48 48
         if not request.user.is_anonymous() and request.user.is_staff:
49 49
             # The user is valid. Continue to the admin page.
  50
+            if request.POST.has_key('post_data'):
  51
+                # User must have re-authenticated through a different window
  52
+                # or tab.
  53
+                request.POST = _decode_post_data(request.POST['post_data'])
50 54
             return view_func(request, *args, **kwargs)
51 55
 
52 56
         assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.middleware.sessions.SessionMiddleware'."
@@ -84,6 +88,8 @@ def _checklogin(request, *args, **kwargs):
84 88
         else:
85 89
             if user.check_password(request.POST.get('password', '')):
86 90
                 request.session[users.SESSION_KEY] = user.id
  91
+                user.last_login = datetime.datetime.now()
  92
+                user.save()
87 93
                 if request.POST.has_key('post_data'):
88 94
                     post_data = _decode_post_data(request.POST['post_data'])
89 95
                     if post_data and not post_data.has_key(LOGIN_FORM_KEY):

0 notes on commit d5a5f0f

Please sign in to comment.
Something went wrong with that request. Please try again.