fix: make API respond to JSON requests

This commit is contained in:
Phan An 2022-07-28 07:48:04 +02:00
parent ac53b6dd00
commit 27ab35a1ae
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC

View file

@ -18,7 +18,7 @@ class Authenticate
public function handle(Request $request, Closure $next) // @phpcs:ignore
{
if ($this->auth->guest()) {
if ($request->ajax() || $request->route()->getName() === 'play') {
if ($request->ajax() || $request->wantsJson() || $request->route()->getName() === 'play') {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('/');