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:
Lance Edgar 2020-09-20 16:32:44 -05:00
parent 711ed947a3
commit 149ae4b71c

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2017 Lance Edgar # Copyright © 2010-2020 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -101,7 +101,10 @@ class TailboneAuthorizationPolicy(object):
if context.request.user and context.request.user.uuid == userid: if context.request.user and context.request.user.uuid == userid:
return context.request.has_perm(permission) return context.request.has_perm(permission)
else: 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) user = Session.query(model.User).get(userid)
if user: if user:
if has_permission(Session(), user, permission): if has_permission(Session(), user, permission):