mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #9978 -- Fixed a KeyError exception that was being raised when using the logout method on the test client on an unauthenticated user, based on patch from ericholscher.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -431,12 +431,14 @@ class Client(object):
|
||||
|
||||
def logout(self):
|
||||
"""
|
||||
Removes the authenticated user's cookies.
|
||||
Removes the authenticated user's cookies and session object.
|
||||
|
||||
Causes the authenticated user to be logged out.
|
||||
"""
|
||||
session = import_module(settings.SESSION_ENGINE).SessionStore()
|
||||
session.delete(session_key=self.cookies[settings.SESSION_COOKIE_NAME].value)
|
||||
session_cookie = self.cookies.get(settings.SESSION_COOKIE_NAME)
|
||||
if session_cookie:
|
||||
session.delete(session_key=session_cookie.value)
|
||||
self.cookies = SimpleCookie()
|
||||
|
||||
def _handle_redirects(self, response):
|
||||
|
||||
Reference in New Issue
Block a user