Merge pull request 'fix/headerauth-crash-missing-header' (#19) from fix/headerauth-crash-missing-header into master

Reviewed-on: #19
This commit is contained in:
Benjamyn Love 2023-10-11 00:58:54 -04:00
commit 84529c373d

View File

@ -15,6 +15,10 @@ class HeaderAuth
*/
public function handle(Request $request, Closure $next): Response
{
if (! $request->hasHeader('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);
}