diff options
| author | Christopher Long <indirecthit@gmail.com> | 2007-06-17 22:18:54 +0000 |
|---|---|---|
| committer | Christopher Long <indirecthit@gmail.com> | 2007-06-17 22:18:54 +0000 |
| commit | ae22b6d403dcf25098c77f0dfcf59ae58b186461 (patch) | |
| tree | c37fc631e99a7e4d909d6b6d236f495003731ea7 /django/contrib/auth/__init__.py | |
| parent | 0cf7bc439129c66df8d64601e885f83b256b4f25 (diff) | |
per-object-permissions: Merged to trunk [5486] NOTE: Not fully tested, will be working on this over the next few weeks.
git-svn-id: http://code.djangoproject.com/svn/django/branches/per-object-permissions@5488 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/auth/__init__.py')
| -rw-r--r-- | django/contrib/auth/__init__.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index dd3b8152e6..14ae020674 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -1,8 +1,8 @@ +import datetime from django.core.exceptions import ImproperlyConfigured SESSION_KEY = '_auth_user_id' BACKEND_SESSION_KEY = '_auth_user_backend' -LOGIN_URL = '/accounts/login/' REDIRECT_FIELD_NAME = 'next' def load_backend(path): @@ -49,8 +49,12 @@ 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 + if hasattr(request, 'user'): + request.user = user def logout(request): """ @@ -64,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 |
