From d26314de20f4165f7276646b97ff70ae18e096ff Mon Sep 17 00:00:00 2001 From: Joseph Silber Date: Wed, 25 May 2016 09:49:44 -0400 Subject: [PATCH] Move the full response logic into the unauthenticated method --- app/Exceptions/Handler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 37653f41..e173d914 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -34,7 +34,11 @@ class Handler extends ExceptionHandler */ protected function unauthenticated($request, AuthenticationException $e) { - parent::unauthenticated($request, $e); + if ($request->ajax() || $request->wantsJson()) { + return response('Unauthorized.', 401); + } else { + return redirect()->guest('login'); + } } /**