From 5547f222e183986e40fc7595633d2cdcbdb5c7fb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 13 Dec 2015 23:22:06 +0200 Subject: [PATCH] Added warning for token mismatch error --- app/Exceptions/Handler.php | 8 ++++++++ resources/lang/en/texts.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 2885957d2b37..ba656f6c0131 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -46,6 +46,14 @@ class Handler extends ExceptionHandler { { if ($e instanceof ModelNotFoundException) { return Redirect::to('/'); + } elseif ($e instanceof \Illuminate\Session\TokenMismatchException) { + // https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e + return redirect() + ->back() + ->withInput($request->except('password', '_token')) + ->with([ + 'warning' => trans('texts.token_expired') + ]); } // In production, except for maintenance mode, we'll show a custom error screen diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index c537c87f1013..7ddad61bc6af 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -975,6 +975,6 @@ return array( 'custom_invoice_charges_helps' => 'Add a text input to the invoice create/edit page and include the charge in the invoice subtotals.', 'color_help' => 'Note: the primary color is also used in the client portal and custom email designs.', - + 'token_expired' => 'Validation token was expired. Please try again.', );