diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-07-20 20:26:10 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-07-20 20:26:10 +0000 |
| commit | c19ef69c5c9435bd3c559f32e34d56ae76c645ac (patch) | |
| tree | 3ef1c820a28433bd934b43a35be870642cf0d946 | |
| parent | c4679bb83fcae7a3cd47d1d54d2a741e75e4abbd (diff) | |
Fixed #2368 -- Fixed KeyError when trying to log out more than once. Thanks, Gary Wilson
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3402 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/auth/__init__.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py index 1c821801ef..a0097a01ed 100644 --- a/django/contrib/auth/__init__.py +++ b/django/contrib/auth/__init__.py @@ -56,8 +56,14 @@ def logout(request): """ Remove the authenticated user's ID from the request. """ - del request.session[SESSION_KEY] - del request.session[BACKEND_SESSION_KEY] + try: + del request.session[SESSION_KEY] + except KeyError: + pass + try: + del request.session[BACKEND_SESSION_KEY] + except KeyError: + pass def get_user(request): from django.contrib.auth.models import AnonymousUser |
