From 8021b9e3e218cbc98c085be98ab1a77ed7151061 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 10 Oct 2023 00:49:29 -0400 Subject: [PATCH] Fixed crash on missing header --- app/Http/Middleware/HeaderAuth.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Http/Middleware/HeaderAuth.php b/app/Http/Middleware/HeaderAuth.php index 3f8d2d3..306e695 100644 --- a/app/Http/Middleware/HeaderAuth.php +++ b/app/Http/Middleware/HeaderAuth.php @@ -15,6 +15,10 @@ class HeaderAuth */ public function handle(Request $request, Closure $next): Response { + if (is_null($request->header('X-BOTAUTH'))) { + return response() + ->json(["status" => false, "message" => "Unauthorized."], 401); + } if (!hash_equals(config('bot.header_auth'), $request->header('X-BOTAUTH'))) { return response('Unauthorized', 401); }