2
在我的控制,我有Yii的accessRules表達不工作
/**
* @return array action filters
*/
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
);
}
/**
* Specifies the access control rules.
* This method is used by the 'accessControl' filter.
* @return array access control rules
*/
public function accessRules()
{
return array(
array('allow', // allow all users to perform 'index' and 'view' actions
'actions'=>array('index','view'),
'users'=>array('*'),
),
array('allow', // allow players to comment on games
'actions'=>array('createComment'),
'roles'=>array('createComment'),
),
array('allow', // allow users to update and delete their own comments
'actions'=>array('deleteComment'),
'expression'=>'return $user->id==Game::model()->findByPk(Yii::app()->getRequest()->getQuery("id"))->author->id;',
),
array('allow', // allow admin users to create, update, delete and manage games
'actions'=>array('admin','create','update','delete','deleteComment'),
'roles'=>array('admin'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
但由於某些原因,在deleteComment表達總是給我一個403錯誤(未授權)。儘管我已經測試了這個表達並且變得真實。即使把'表達'=>'返回true;'不起作用。 :(我完全糊塗了...任何想法 謝謝,布拉德(?:。