[roles] controller: Fixed setting permissions

This commit is contained in:
Ferdinand Thiessen 2021-04-04 21:46:51 +02:00
parent 064177542e
commit 03aa7a3231
1 changed files with 1 additions and 2 deletions

View File

@ -44,12 +44,11 @@ def update_role(role, new_name):
def set_permissions(role, permissions):
role.permissions.clear()
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.extend(p)
role.permissions = list(p)
db.session.commit()