Commit cedde2d9 authored by Taylor Otwell's avatar Taylor Otwell

cleaning up

parent 3ddaf3f9
...@@ -4,10 +4,6 @@ namespace App\Exceptions; ...@@ -4,10 +4,6 @@ namespace App\Exceptions;
use Exception; use Exception;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
...@@ -19,28 +15,12 @@ class Handler extends ExceptionHandler ...@@ -19,28 +15,12 @@ class Handler extends ExceptionHandler
*/ */
protected $dontReport = [ protected $dontReport = [
AuthenticationException::class, AuthenticationException::class,
AuthorizationException::class, \Illuminate\Auth\Access\AuthorizationException::class,
HttpException::class, \Symfony\Component\HttpKernel\Exception\HttpException::class,
ModelNotFoundException::class, \Illuminate\Database\Eloquent\ModelNotFoundException::class,
ValidationException::class, \Illuminate\Validation\ValidationException::class,
]; ];
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function unauthenticated($request, AuthenticationException $e)
{
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
/** /**
* Report or log an exception. * Report or log an exception.
* *
...@@ -65,4 +45,20 @@ class Handler extends ExceptionHandler ...@@ -65,4 +45,20 @@ class Handler extends ExceptionHandler
{ {
return parent::render($request, $e); return parent::render($request, $e);
} }
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $e
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $e)
{
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