fix: increment bad requests when trying to access authed endpoint

without a token
This commit is contained in:
2025-05-27 01:33:04 +02:00
parent 4893715118
commit 69e911b1b8

View File

@@ -20,6 +20,7 @@ def require_authentication(func):
except:
raise AssertionError(f"Function \"{func.__name__}\" does not return status, code, and data as it should!")
else:
increment_bad_requests()
return 401, "error", {'error_msg': "Unauthorized"}
return wrapper
@@ -33,7 +34,7 @@ def not_implemented(data):
def stub_hello():
return 200, 'hello from v1! stats are at /api/v1/stats', []
def epochToDate(epoch):
def epoch_to_date(epoch):
return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(epoch))
def stats():
@@ -53,7 +54,7 @@ def get_matches():
@require_authentication
def debugger_halt(r):
print(f"{c.WARNING}[{epochToDate(time.time())}]{c.ENDC} {r.remote_addr} triggered a debugger halt!")
print(f"{c.WARNING}[{epoch_to_date(time.time())}]{c.ENDC} {r.remote_addr} triggered a debugger halt!")
breakpoint()
return 200, "ok", []