Fix bug when request.user becomes unattached from session (?)
this sure seems unexpected. so far the behavior has only been seen on mobile when a new ordering batch was created
This commit is contained in:
parent
961249722f
commit
6ae129ea24
|
@ -47,7 +47,12 @@ class View(object):
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
# if user becomes inactive while logged in, log them out
|
# if user becomes inactive while logged in, log them out
|
||||||
if getattr(request, 'user', None) and not request.user.active:
|
if getattr(request, 'user', None):
|
||||||
|
# TODO: why is the user sometimes not attached to session?
|
||||||
|
# (this has only been seen on mobile, when creating a new ordering batch)
|
||||||
|
if request.user not in Session():
|
||||||
|
request.user = Session.merge(request.user)
|
||||||
|
if not request.user.active:
|
||||||
headers = logout_user(request)
|
headers = logout_user(request)
|
||||||
raise self.redirect(request.route_url('home'))
|
raise self.redirect(request.route_url('home'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue