Yii中的筛选器未返回
我正在尝试使用YII中的用户过滤器。 这是我的密码Yii中的筛选器未返回,yii,yii-filters,Yii,Yii Filters,我正在尝试使用YII中的用户过滤器。 这是我的密码 public function filters() { return array( 'provideronly +uploadclients,fileview,editprofile,getinvitedusers', ); } public function filterProvideronly($filterchain) { if(Yii::app()->user->
public function filters()
{
return array(
'provideronly +uploadclients,fileview,editprofile,getinvitedusers',
);
}
public function filterProvideronly($filterchain)
{
if(Yii::app()->user->providerId==-1)
{
$this->redirect(array('site/error','id'=>403,'message'=>'You are unauthorized to view this page'));
return false;
}
return true;
}
当用户未经授权使用控制器时,它将重定向到错误页面。但是当用户被授权时,它会显示一个空白页
这段代码有什么问题?您需要将$filterChain->run放入,而不是返回true;因此,我可以看到筛选器已结束。似乎您已经知道必须调用$filterChain->run。请看一下手册。