bug 565759, already logged in user not relogged in

This commit is contained in:
Dave Dash 2010-05-13 15:39:36 -07:00
Родитель 857e5277c5
Коммит 183f557885
1 изменённых файлов: 2 добавлений и 13 удалений

Просмотреть файл

@ -23,6 +23,8 @@ class CakeCookieMiddleware(object):
Look up the AMOv3 session id in the table and login the user if it's
valid.
"""
if request.user.is_authenticated():
return
id = request.COOKIES.get('AMOv3')
@ -32,18 +34,5 @@ class CakeCookieMiddleware(object):
user = auth.authenticate(session=session)
if user is not None:
auth.login(request, user)
SESSION_KEY = '_auth_user_id'
BACKEND_SESSION_KEY = '_auth_user_backend'
if SESSION_KEY in request.session:
if request.session[SESSION_KEY] != user.id:
# To avoid reusing another user's session, create a new, empty
# session if the existing session corresponds to a different
# authenticated user.
request.session.flush()
else:
request.session.cycle_key()
request.session[SESSION_KEY] = user.id
request.session[BACKEND_SESSION_KEY] = user.backend
request.user = user
except Session.DoesNotExist:
return