Skip to content

Instantly share code, notes, and snippets.

@zabaala
Last active October 19, 2017 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zabaala/a94ddc76439689c4706e3181a34ec8e6 to your computer and use it in GitHub Desktop.
Save zabaala/a94ddc76439689c4706e3181a34ec8e6 to your computer and use it in GitHub Desktop.
Override Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php class
<?php
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*
*/
public function handle($request, Closure $next)
{
if ($this->isReading($request) ||
$this->runningUnitTests() ||
$this->shouldPassThrough($request) ||
$this->tokensMatch($request)
) {
return $this->addCookieToResponse($request, $next($request));
}
return redirect()->back()
->with('custom_error', 'Sorry. For security reason, reload this page and try submit the form again.');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment