我在使用restful控制器。我需要运行一些过滤器,如auth和自定义权限。所以我把他们分成了一个路由组,并在那组上设置过滤器。此外,我还想运行csrf过滤器,但只对post请求。如何在路线组中做到这一点?
添加澄清代码
Route::group(array('before' => 'auth|allowed|csrf'), function() {
Route::controller('controller', 'SomeController');
Route::controller('othercontroller', 'OtherController');
});我要中央应急基金只在邮政路线上。我真的不想在每个控制器上添加一个过滤器(有相当多的);
发布于 2013-09-20 18:24:00
好的。我想我解决了。我检查了请求是否是邮寄的。不知道这是不是不好的做法。我将filter.php中的csrf过滤器更改为
Route::filter('csrf', function()
{
if (Request::getMethod() == 'POST' && Session::token() != Input::get('_token'))
{
throw new Illuminate\Session\TokenMismatchException;
}
});https://stackoverflow.com/questions/18900130
复制相似问题