FEATURE #1386: catch CSRF token exception
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Illuminate\Session\TokenMismatchException;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
@@ -45,6 +46,11 @@ class Handler extends ExceptionHandler
|
|||||||
*/
|
*/
|
||||||
public function render($request, Exception $e)
|
public function render($request, Exception $e)
|
||||||
{
|
{
|
||||||
|
if ($e instanceof TokenMismatchException){
|
||||||
|
//redirect to form an example of how I handle mine
|
||||||
|
return redirect($request->fullUrl())->with('error', trans('validation.csrf'));
|
||||||
|
}
|
||||||
|
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ return [
|
|||||||
],
|
],
|
||||||
'boolean' => 'The :attribute field must be true or false.',
|
'boolean' => 'The :attribute field must be true or false.',
|
||||||
'confirmed' => 'The :attribute confirmation does not match.',
|
'confirmed' => 'The :attribute confirmation does not match.',
|
||||||
|
'csrf' => 'Opps! Seems you could not submit form for a longtime. Please try again',
|
||||||
'date' => 'The :attribute is not a valid date.',
|
'date' => 'The :attribute is not a valid date.',
|
||||||
'date_format' => 'The :attribute does not match the format :format.',
|
'date_format' => 'The :attribute does not match the format :format.',
|
||||||
'different' => 'The :attribute and :other must be different.',
|
'different' => 'The :attribute and :other must be different.',
|
||||||
@@ -76,7 +77,6 @@ return [
|
|||||||
'timezone' => 'The :attribute must be a valid zone.',
|
'timezone' => 'The :attribute must be a valid zone.',
|
||||||
'unique' => 'The :attribute has already been taken.',
|
'unique' => 'The :attribute has already been taken.',
|
||||||
'url' => 'The :attribute format is invalid.',
|
'url' => 'The :attribute format is invalid.',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Custom Validation Language Lines
|
| Custom Validation Language Lines
|
||||||
@@ -93,7 +93,6 @@ return [
|
|||||||
'rule-name' => 'custom-message',
|
'rule-name' => 'custom-message',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Custom Validation Attributes
|
| Custom Validation Attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user