Fixed crash on missing header

This commit is contained in:
ben 2023-10-10 00:49:29 -04:00
parent acc56a0cdf
commit 8021b9e3e2

View File

@ -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);
}