mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix role permissions
This commit is contained in:
parent
88fd46282d
commit
b1a7142dc0
@ -131,8 +131,16 @@ class ApiRolesRoleIndexHandler(BaseApiHandler):
|
||||
_,
|
||||
) = auth_data
|
||||
|
||||
if not superuser:
|
||||
return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"})
|
||||
role = self.controller.roles.get_role(role_id)
|
||||
if not superuser and user["user_id"] != role["manager"]:
|
||||
return self.finish_json(
|
||||
400,
|
||||
{
|
||||
"status": "error",
|
||||
"error": "NOT_AUTHORIZED",
|
||||
"error_data": "Not Authorized",
|
||||
},
|
||||
)
|
||||
|
||||
try:
|
||||
data = orjson.loads(self.request.body)
|
||||
|
@ -151,11 +151,12 @@ class ApiUsersIndexHandler(BaseApiHandler):
|
||||
400, {"status": "error", "error": "INVALID_SUPERUSER_CREATE"}
|
||||
)
|
||||
|
||||
if len(roles) != 0 and not superuser:
|
||||
# HACK: This should check if the user has the roles or something
|
||||
return self.finish_json(
|
||||
400, {"status": "error", "error": "INVALID_ROLES_CREATE"}
|
||||
)
|
||||
for role in roles:
|
||||
role = self.controller.roles.get_role(role)
|
||||
if int(role["manager"]) != int(auth_data[4]["user_id"]) and not superuser:
|
||||
return self.finish_json(
|
||||
400, {"status": "error", "error": "INVALID_ROLES_CREATE"}
|
||||
)
|
||||
|
||||
# TODO: do this in the most efficient way
|
||||
user_id = self.controller.users.add_user(
|
||||
|
Loading…
Reference in New Issue
Block a user