mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Add audit log end point
This commit is contained in:
parent
a8894757cf
commit
52e44f090e
@ -50,6 +50,7 @@ from app.classes.web.routes.api.users.user.permissions import (
|
||||
from app.classes.web.routes.api.users.user.pfp import ApiUsersUserPfpHandler
|
||||
from app.classes.web.routes.api.users.user.public import ApiUsersUserPublicHandler
|
||||
from app.classes.web.routes.api.crafty.config.index import ApiCraftyConfigIndexHandler
|
||||
from app.classes.web.routes.api.crafty.clogs.index import ApiCraftyLogIndexHandler
|
||||
|
||||
|
||||
def api_handlers(handler_args):
|
||||
@ -70,6 +71,11 @@ def api_handlers(handler_args):
|
||||
ApiCraftyConfigIndexHandler,
|
||||
handler_args,
|
||||
),
|
||||
(
|
||||
r"/api/v2/crafty/logs/([a-z0-9_]+)/?",
|
||||
ApiCraftyLogIndexHandler,
|
||||
handler_args,
|
||||
),
|
||||
# User routes
|
||||
(
|
||||
r"/api/v2/users/?",
|
||||
|
34
app/classes/web/routes/api/crafty/clogs/index.py
Normal file
34
app/classes/web/routes/api/crafty/clogs/index.py
Normal file
@ -0,0 +1,34 @@
|
||||
from app.classes.web.base_api_handler import BaseApiHandler
|
||||
|
||||
|
||||
class ApiCraftyLogIndexHandler(BaseApiHandler):
|
||||
def get(self, log_type: str):
|
||||
auth_data = self.authenticate_user()
|
||||
if not auth_data:
|
||||
return
|
||||
(
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
superuser,
|
||||
_,
|
||||
) = auth_data
|
||||
|
||||
if not superuser:
|
||||
return self.finish_json(400, {"status": "error", "error": "NOT_AUTHORIZED"})
|
||||
|
||||
log_types = ["audit", "session", "schedule"]
|
||||
if log_type not in log_types:
|
||||
raise NotImplementedError
|
||||
|
||||
if log_type == "audit":
|
||||
return self.finish_json(
|
||||
200,
|
||||
{"status": "ok", "data": self.controller.management.get_activity_log()},
|
||||
)
|
||||
|
||||
if log_type == "session":
|
||||
raise NotImplementedError
|
||||
|
||||
if log_type == "schedule":
|
||||
raise NotImplementedError
|
Loading…
x
Reference in New Issue
Block a user