Ticket #1234: last_login_clear_pass.diff

File last_login_clear_pass.diff, 1.7 KB (added by oggie rob <oz.robharvey@…>, 19 years ago)

fixes multiple window login problem and updates last_login

  • contrib/admin/views/decorators.py

     
    44from django.utils import httpwrappers
    55import base64, md5
    66import cPickle as pickle
     7import datetime
    78
    89ERROR_MESSAGE = "Please enter a correct username and password. Note that both fields are case-sensitive."
    910LOGIN_FORM_KEY = 'this_is_the_login_form'
     
    4647    def _checklogin(request, *args, **kwargs):
    4748        if not request.user.is_anonymous() and request.user.is_staff:
    4849            # The user is valid. Continue to the admin page.
     50            if request.POST.has_key('post_data'):
     51                # we must have re-authenticated through a different window or tab
     52                request.POST = _decode_post_data(request.POST['post_data'])
    4953            return view_func(request, *args, **kwargs)
    5054
    5155        assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.middleware.sessions.SessionMiddleware'."
     
    8387        else:
    8488            if user.check_password(request.POST.get('password', '')):
    8589                request.session[users.SESSION_KEY] = user.id
     90                # keep track of last login
     91                user.last_login = datetime.datetime.now()
     92                user.save()
    8693                if request.POST.has_key('post_data'):
    8794                    post_data = _decode_post_data(request.POST['post_data'])
    8895                    if post_data and not post_data.has_key(LOGIN_FORM_KEY):
Back to Top