From 74bab891783a6f85d7b8f8c5908bde046622654e Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Wed, 25 Apr 2007 09:44:06 +0000 Subject: [PATCH] Fixed #3379 -- Changed login() so that we update last_login when a user logs in. Thanks, arvin. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5074 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/views/decorators.py | 2 -- django/contrib/auth/__init__.py | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py index 9dfe651fe6..bdd8257b2e 100644 --- a/django/contrib/admin/views/decorators.py +++ b/django/contrib/admin/views/decorators.py @@ -90,8 +90,6 @@ def staff_member_required(view_func): if user.is_active and user.is_staff: login(request, user) # TODO: set last_login with an event. - user.last_login = datetime.datetime.now() - user.save() if request.POST.has_key('post_data'): post_data = _decode_post_data(request.POST['post_data']) if post_data and not post_data.has_key(LOGIN_FORM_KEY): diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index 8c92732f44..d37450805f 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -1,3 +1,4 @@ +import datetime from django.core.exceptions import ImproperlyConfigured SESSION_KEY = '_auth_user_id' @@ -48,6 +49,8 @@ def login(request, user): if user is None: user = request.user # TODO: It would be nice to support different login methods, like signed cookies. + user.last_login = datetime.datetime.now() + user.save() request.session[SESSION_KEY] = user.id request.session[BACKEND_SESSION_KEY] = user.backend