fix(roles): Minor fix in set_permissions

This commit is contained in:
Ferdinand Thiessen 2021-12-18 04:19:07 +01:00
parent 1db3391826
commit 691345cf40
1 changed files with 5 additions and 6 deletions

View File

@ -46,11 +46,10 @@ def update_role(role, new_name):
def set_permissions(role, permissions):
for name in permissions:
p = Permission.query.filter(Permission.name.in_(permissions)).all()
if not p or len(p) < len(permissions):
raise BadRequest("Invalid permission name >{}<".format(name))
role.permissions = list(p)
perms = Permission.query.filter(Permission.name.in_(permissions)).all()
if len(perms) < len(permissions):
raise BadRequest("Invalid permission name")
role.permissions = list(perms)
db.session.commit()