Skip to content

Instantly share code, notes, and snippets.

@jadulled
Forked from petehouston/VerifyCsrfToken.php
Last active August 29, 2015 14:23
Show Gist options
  • Save jadulled/4825c3d780bc80d14b8d to your computer and use it in GitHub Desktop.
Save jadulled/4825c3d780bc80d14b8d to your computer and use it in GitHub Desktop.
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
class VerifyCsrfToken extends BaseVerifier {
/**
* Exclude route from CSRF check
* @var array
*/
protected $excludeRoutes = [
'home/exclude',
'page/about',
'page/terms',
// add any route to exclude here
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
foreach($this->excludeRoutes as $route) {
if ($request->is($route)) {
return $next($request);
}
}
return parent::handle($request, $next);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment