non admin can't change app roles

This commit is contained in:
Davor 2022-07-09 12:18:03 +02:00 committed by Maarten de Waard
parent 53529cd737
commit 5b55c4498b

View file

@ -1,5 +1,6 @@
from database import db from database import db
from areas.apps.models import App, AppRole from areas.apps.models import App, AppRole
from areas.roles.role_service import RoleService
from helpers import KratosApi from helpers import KratosApi
class UserService: class UserService:
@ -76,9 +77,9 @@ class UserService:
} }
KratosApi.put("/admin/identities/{}".format(id), kratos_data) KratosApi.put("/admin/identities/{}".format(id), kratos_data)
# TODO: if the user is no admin - he can't change app roles - implement is_admin = RoleService.is_user_admin(id)
if data["app_roles"]: if is_admin and data["app_roles"]:
app_roles = data["app_roles"] app_roles = data["app_roles"]
for ar in app_roles: for ar in app_roles:
app = App.query.filter_by(slug=ar["name"]).first() app = App.query.filter_by(slug=ar["name"]).first()