mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
multi-auth: Updated middleware to use new auth api.
git-svn-id: http://code.djangoproject.com/svn/django/branches/multi-auth@2886 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
63ffc57e58
commit
cfdfb1088b
@ -4,12 +4,8 @@ class LazyUser(object):
|
|||||||
|
|
||||||
def __get__(self, request, obj_type=None):
|
def __get__(self, request, obj_type=None):
|
||||||
if self._user is None:
|
if self._user is None:
|
||||||
from django.contrib.auth.models import User, AnonymousUser, SESSION_KEY
|
from django.contrib.auth import get_user
|
||||||
try:
|
self._user = get_user(request)
|
||||||
user_id = request.session[SESSION_KEY]
|
|
||||||
self._user = User.objects.get(pk=user_id)
|
|
||||||
except (KeyError, User.DoesNotExist):
|
|
||||||
self._user = AnonymousUser()
|
|
||||||
return self._user
|
return self._user
|
||||||
|
|
||||||
class AuthenticationMiddleware:
|
class AuthenticationMiddleware:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user