Return JSON for unauthenticated AJAX requests
This commit is contained in:
parent
bd358bdc0f
commit
8e7672fc04
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue