2012-07-06 39 views
3

我创造了Yii框架某种管理面板和IM登录时这样Yii框架不检查角色accessRules

public function authenticate() 
{ 

    $record=AdminTbl::model()->findByAttributes(array('usr'=>$this->username)); 
    if($record===null) 
     $this->errorCode=self::ERROR_USERNAME_INVALID; 
    else if($record->pwd!==$this->password) 
     $this->errorCode=self::ERROR_PASSWORD_INVALID; 
    else 
    { 
     $this->_id=$record->id; 
     $this->setState('roles','main'); 
     $this->errorCode=self::ERROR_NONE; 
    } 
    return !$this->errorCode; 
} 

我检查,如果国家真的设置的设置状态,呼应了上图。后来我把accessrules()

public function accessRules() 
{ 
    return array(
     array('allow', // allow all users to perform 'index' and 'view' actions 
      'actions'=>array('index','view','create','update','admin','delete'), 
      'roles'=>array('main'), 
     ), 
     array('deny', // deny all users 
      'users'=>array('*'), 
     ), 
    ); 
} 

,我不能访问该用户登录这些网页这个角色。这是什么问题?

回答