mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-31 12:56:11 +01:00
Appease the linter
This commit is contained in:
parent
b34ecf58c2
commit
4051d98f8f
@ -17,8 +17,14 @@ class ApiUsersUserKeyHandler(BaseApiHandler):
|
|||||||
key = self.controller.users.get_user_api_key(key_id)
|
key = self.controller.users.get_user_api_key(key_id)
|
||||||
# does this user id exist?
|
# does this user id exist?
|
||||||
if key is None:
|
if key is None:
|
||||||
self.redirect("/panel/error?error=Invalid Key ID")
|
return self.finish_json(
|
||||||
return
|
400,
|
||||||
|
{
|
||||||
|
"status": "error",
|
||||||
|
"error": "INVALID DATA",
|
||||||
|
"error_data": "INVALID KEY",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
str(key.user_id) != str(auth_data[4]["user_id"])
|
str(key.user_id) != str(auth_data[4]["user_id"])
|
||||||
@ -48,37 +54,37 @@ class ApiUsersUserKeyHandler(BaseApiHandler):
|
|||||||
200,
|
200,
|
||||||
{"status": "ok", "data": data_key},
|
{"status": "ok", "data": data_key},
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
if (
|
if (
|
||||||
str(user_id) != str(auth_data[4]["user_id"])
|
str(user_id) != str(auth_data[4]["user_id"])
|
||||||
and not auth_data[4]["superuser"]
|
and not auth_data[4]["superuser"]
|
||||||
):
|
):
|
||||||
return self.finish_json(
|
return self.finish_json(
|
||||||
400,
|
400,
|
||||||
{
|
|
||||||
"status": "error",
|
|
||||||
"error": "NOT AUTHORIZED",
|
|
||||||
"error_data": "TRIED TO EDIT KEY WIHTOUT AUTH",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
keys = []
|
|
||||||
for key in self.controller.users.get_user_api_keys(str(user_id)):
|
|
||||||
keys.append(
|
|
||||||
{
|
|
||||||
"id": key.token_id,
|
|
||||||
"name": key.name,
|
|
||||||
"server_permissions": key.server_permissions,
|
|
||||||
"crafty_permissions": key.crafty_permissions,
|
|
||||||
"superuser": key.superuser,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
self.finish_json(
|
|
||||||
200,
|
|
||||||
{
|
{
|
||||||
"status": "ok",
|
"status": "error",
|
||||||
"data": keys,
|
"error": "NOT AUTHORIZED",
|
||||||
|
"error_data": "TRIED TO EDIT KEY WIHTOUT AUTH",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
keys = []
|
||||||
|
for key in self.controller.users.get_user_api_keys(str(user_id)):
|
||||||
|
keys.append(
|
||||||
|
{
|
||||||
|
"id": key.token_id,
|
||||||
|
"name": key.name,
|
||||||
|
"server_permissions": key.server_permissions,
|
||||||
|
"crafty_permissions": key.crafty_permissions,
|
||||||
|
"superuser": key.superuser,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.finish_json(
|
||||||
|
200,
|
||||||
|
{
|
||||||
|
"status": "ok",
|
||||||
|
"data": keys,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
def patch(self, user_id: str):
|
def patch(self, user_id: str):
|
||||||
user_key_schema = {
|
user_key_schema = {
|
||||||
@ -187,8 +193,14 @@ class ApiUsersUserKeyHandler(BaseApiHandler):
|
|||||||
key = self.controller.users.get_user_api_key(key_id)
|
key = self.controller.users.get_user_api_key(key_id)
|
||||||
# does this user id exist?
|
# does this user id exist?
|
||||||
if key is None:
|
if key is None:
|
||||||
self.redirect("/panel/error?error=Invalid Key ID")
|
return self.finish_json(
|
||||||
return
|
400,
|
||||||
|
{
|
||||||
|
"status": "error",
|
||||||
|
"error": "INVALID DATA",
|
||||||
|
"error_data": "INVALID KEY",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
# does this user id exist?
|
# does this user id exist?
|
||||||
target_key = self.controller.users.get_user_api_key(key_id)
|
target_key = self.controller.users.get_user_api_key(key_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user