xxxxxxxxxx
There is a way to override this view. All you need to do is
create 419.blade.php file inside the resources/views/errors folder.
If you need to find the Laravel`s default 419.blade.php file , you can publish
vendor files:
php artisan vendor:publish --tag=laravel-errors
Add the following to App/Exceptions/Handler.php inside the register method
xxxxxxxxxx
$this->renderable(function (\Exception $e) {
if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) {
return redirect()->to(url()->previous()); //to return to previous url
//return redirect()->route('login'); //to return to a specific route
};
});
xxxxxxxxxx
abort(419, 'Authentication Timeout');
// OR
return redirect()->route('login')->withErrors([
'message' => 'Authentication Timeout',
]);