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:
Lance Edgar 2017-08-02 13:18:19 -05:00
parent 961249722f
commit 6ae129ea24

View file

@ -47,7 +47,12 @@ class View(object):
self.request = request
# 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)
raise self.redirect(request.route_url('home'))