Commit c6931d26 authored by Taylor Otwell's avatar Taylor Otwell

Merge pull request #3635 from JacobBennett/patch-1

[5.2] Don't return a login page to a JSON request
parents e46a73dd 5b3c5f3f
......@@ -18,7 +18,7 @@ class Authenticate
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment