from django.contrib.auth.views import logout as original_logout
from django.contrib.auth.views import login as original_login
from django.contrib.sessions.backends.base import SessionBase
def alt_logout(request, *args, **kwargs):
"""
Info on why this exists: http://code.djangoproject.com/ticket/6941
Clears out any session data on logout that would otherwise persist
for any subsequent logins regardless of user_id.
"""
for sesskey in request.session.keys():
del request.session[sesskey]
return original_logout(request, *args, **kwargs)
def alt_login(request, *args, **kwargs):
"""
Info on why this exists: http://code.djangoproject.com/ticket/6941
Clears out any session data on login that would otherwise persist
for any subsequent logins regardless of user_id.
Session data is only cleared if the test cookie is not present.
If its present, the session data is already cleared and this does nothing.
"""
if SessionBase.TEST_COOKIE_NAME not in request.session:
for sesskey in request.session.keys():
del request.session[sesskey]
return original_login(request, *args, **kwargs)
Comments
This has now been corrected in the trunk.
http://code.djangoproject.com/changeset/8343
#