/** * 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(); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $this->except = array_merge($this->except, static::$staticExcept); return parent::handle($request, $next); }
/** * Create a new middleware instance. * * @param \Illuminate\Foundation\Application $app * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter * * @return void */ public function __construct(Application $app, Encrypter $encrypter) { $this->except[] = 'api.filemanager'; parent::__construct($app, $encrypter); }