Merge pull request #3817 from JosephSilber/unauthenticated-json

[5.3] Return JSON for unauthenticated AJAX requests
This commit is contained in:
Taylor Otwell 2016-06-22 08:38:13 -05:00 committed by GitHub
commit 51addd6c63
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ public function render($request, Exception $e)
protected function unauthenticated($request, AuthenticationException $e)
{
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
return response()->json(['error' => 'Unauthenticated.'], 401);
} else {
return redirect()->guest('login');
}