Return JSON for unauthenticated AJAX requests

This commit is contained in:
Joseph Silber 2016-06-22 08:46:26 -04:00
parent bd358bdc0f
commit 8e7672fc04
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');
}