From 44dd91ec6d39525e52b78f7fff6de8531b980f5f Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 15 Jun 2007 01:53:40 +0000 Subject: [PATCH] Fixed #4015 -- Changed login() and logout() messages to update request.user if it is relevant. Thanks James Bennett, Vinay Sajip and Gary Wilson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5472 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/auth/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index d37450805f..14ae020674 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -53,6 +53,8 @@ def login(request, user): user.save() request.session[SESSION_KEY] = user.id request.session[BACKEND_SESSION_KEY] = user.backend + if hasattr(request, 'user'): + request.user = user def logout(request): """ @@ -66,6 +68,9 @@ def logout(request): del request.session[BACKEND_SESSION_KEY] except KeyError: pass + if hasattr(request, 'user'): + from django.contrib.auth.models import AnonymousUser + request.user = AnonymousUser() def get_user(request): from django.contrib.auth.models import AnonymousUser