Yii Framework Forum

Why the accessRules doesen't work in my yii module, the yii version is 1.1

(George_lu) #1

I want to make the authenticated users can access my


My accessRules is as below:

public function accessRules()
        return array(
            array('allow',  // allow only users in the 'admin' role access to our actions
                'actions'=>array('index','view', 'create', 'update', 'admin', 'delete'),
            array('deny',  // deny all users

But, when the authenticated users tried to access my

admin(module)/sysMessage(controller)/index(action), they got this message:

“Error 403 You are not authorized to perform this action.”

Could you tell me why?

(George_lu) #2

When we use the module/controller/action, we should check the


I changed the “public function beforeControllerAction” as below, so the problem be solved.

refer:Create AccessRules in modules Yii Framework

public function beforeControllerAction($controller, $action)
      if(parent::beforeControllerAction($controller, $action))
      // this method is called before any module controller action is performed
       // you may place customized code here

     $url = Yii::app()->createUrl(Yii::app()->user->loginUrl);
     Yii::app()->user->returnUrl = Yii::app()->createUrl('/admin/');
     else {
       return true;

     return false;