Skip to content

A free open source IT asset/license management system

Removed poop

snipe80e047f6798d
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index c35b82a436..c73877e247 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -3,10 +3,7 @@
namespace App\Exceptions;
use Exception;
-use Illuminate\Validation\ValidationException;
-use Illuminate\Auth\Access\AuthorizationException;
-use Illuminate\Database\Eloquent\ModelNotFoundException;
-use Symfony\Component\HttpKernel\Exception\HttpException;
+use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
@@ -17,10 +14,12 @@ class Handler extends ExceptionHandler
* @var array
*/
protected $dontReport = [
- AuthorizationException::class,
- HttpException::class,
- ModelNotFoundException::class,
- ValidationException::class,
+ \Illuminate\Auth\AuthenticationException::class,
+ \Illuminate\Auth\Access\AuthorizationException::class,
+ \Symfony\Component\HttpKernel\Exception\HttpException::class,
+ \Illuminate\Database\Eloquent\ModelNotFoundException::class,
+ \Illuminate\Session\TokenMismatchException::class,
+ \Illuminate\Validation\ValidationException::class,
];
/**
@@ -28,19 +27,19 @@ class Handler extends ExceptionHandler
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
- * @param \Exception $e
+ * @param \Exception $exception
* @return void
*/
- public function report(Exception $e)
+ public function report(Exception $exception)
{
- parent::report($e);
+ parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
- * @param \Exception $e
+ * @param \Exception $exception
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
@@ -57,11 +56,28 @@ class Handler extends ExceptionHandler
case '404':
return response()->view('layouts/basic', [
- 'content' => view('errors/404')
+ 'content' => view('errors/404')
]);
}
}
return parent::render($request, $e);
+
+ }
+
+ /**
+ * Convert an authentication exception into an unauthenticated response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Auth\AuthenticationException $exception
+ * @return \Illuminate\Http\Response
+ */
+ protected function unauthenticated($request, AuthenticationException $exception)
+ {
+ if ($request->expectsJson()) {
+ return response()->json(['error' => 'Unauthenticated.'], 401);
+ }
+
+ return redirect()->guest('login');
}
}