I don't know what was wrong with @laravelcode's code, but he got the right idea--add the check for TokenMismatchException
to render
method of App\Exception\Handler
class, as per documentation.
Here's mine (irrelevant parts skipped):
<?php namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Session\TokenMismatchException;
class Handler extends ExceptionHandler {
public function render($request, Exception $e)
{
if ($e instanceof TokenMismatchException) {
return redirect()->back()->with('message', 'Security token expired. Please, repeat your request.');
}
return parent::render($request, $e);
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community