0.8.81: Fix uploads, the admin before_post should be before the global before_post

This commit is contained in:
Fijxu 2024-08-18 22:02:36 -04:00
parent cea1982523
commit 69fe5a3c58
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 9 additions and 11 deletions

View file

@ -1,2 +0,0 @@
module LOGGER
end

View file

@ -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