/**
* Handle the request.
*
* @param \Illuminate\Http\Request $request
* @param callable $next
* @return \Illuminate\Http\RedirectResponse|mixed
*/
public function handle($request, Closure $next)
{
// If the method is not a post - skip.
if (!$request->isMethod('post')) {
return $next($request);
}
// Get the route action.
$action = $this->route->getAction();
// If the route disabled the CSRF - skip.
if (array_get($action, 'csrf') === false) {
return $next($request);
}
/**
* Try validating the CSRF token with the
* base Laravel Middleware.
*/
try {
return parent::handle($request, $next);
} catch (TokenMismatchException $e) {
$this->messages->error('streams::message.csrf_token_mismatch');
return $this->redirector->back();
}
}