From 69fe5a3c58123eed341860a3f9626dd08e1f7847 Mon Sep 17 00:00:00 2001 From: Fijxu Date: Sun, 18 Aug 2024 22:02:36 -0400 Subject: [PATCH] 0.8.81: Fix uploads, the admin before_post should be before the global before_post --- src/log.cr | 2 -- src/routing.cr | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) delete mode 100644 src/log.cr diff --git a/src/log.cr b/src/log.cr deleted file mode 100644 index cf78a20..0000000 --- a/src/log.cr +++ /dev/null @@ -1,2 +0,0 @@ -module LOGGER -end diff --git a/src/routing.cr b/src/routing.cr index 732cd83..9211b43 100644 --- a/src/routing.cr +++ b/src/routing.cr @@ -18,6 +18,12 @@ module Routing end end + before_post "/api/admin/*" do |env| + if env.request.headers.try &.["X-Api-Key"]? != CONFIG.adminApiKey || nil + halt env, status_code: 401, response: error401("Wrong API Key") + end + end + before_post do |env| if env.request.headers.try &.["X-Api-Key"]? == CONFIG.adminApiKey # Skips Tor and Rate limits if the API key matches @@ -45,12 +51,6 @@ module Routing end end - before_post "/api/admin" do |env| - if env.request.headers.try &.["X-Api-Key"]? != CONFIG.adminApiKey || nil - error401 "Wrong API Key" - end - end - def register_all get "/" do |env| host = Utils.host(env) @@ -91,9 +91,9 @@ module Routing def register_admin if CONFIG.adminEnabled - post "/api/admin/upload" do |env| - Handling::Admin.delete_ip_limit(env) - end + # post "/api/admin/upload" do |env| + # Handling::Admin.delete_ip_limit(env) + # end post "/api/admin/delete" do |env| Handling::Admin.delete_file(env) end