Avoid unhelpful error when perm check happens for "re-created" DB user
kind of an edge case, should only apply to dev
This commit is contained in:
parent
711ed947a3
commit
149ae4b71c
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2017 Lance Edgar
|
||||
# Copyright © 2010-2020 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -101,7 +101,10 @@ class TailboneAuthorizationPolicy(object):
|
|||
if context.request.user and context.request.user.uuid == userid:
|
||||
return context.request.has_perm(permission)
|
||||
else:
|
||||
assert False # should no longer happen..right?
|
||||
# this is pretty rare, but can happen in dev after
|
||||
# re-creating the database, which means new user uuids.
|
||||
# TODO: the odds of this query returning a user in that
|
||||
# case, are probably nil, and we should just skip this bit?
|
||||
user = Session.query(model.User).get(userid)
|
||||
if user:
|
||||
if has_permission(Session(), user, permission):
|
||||
|
|
Loading…
Reference in a new issue