Commit 85fc8fec authored by Micheal Mand's avatar Micheal Mand Committed by Nicolas Widart

Add more graceful handling of TokenMismatchException (#300)

parent 09746122
......@@ -62,6 +62,7 @@ return [
'create resource' => 'Create :name',
'edit resource' => 'Edit :name',
'destroy resource' => 'Delete :name',
'error token mismatch' => 'Your session timed out, please submit the form again.',
'error 404' => '404',
'error 404 title' => 'Oops! This page was not found.',
'error 404 description' => 'The page you are looking for was not found.',
......
......@@ -3,6 +3,7 @@
namespace App\Exceptions;
use Exception;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
......@@ -23,6 +24,7 @@ class Handler extends ExceptionHandler
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
TokenMismatchException::class,
ValidationException::class,
];
......@@ -63,6 +65,12 @@ class Handler extends ExceptionHandler
return $this->handleExceptions($e);
}
if ($e instanceof TokenMismatchException) {
return redirect()->back()
->withInput($request->except('password'))
->withErrors(trans('core::core.error token mismatch'));
}
return parent::render($request, $e);
}
......
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