2012-07-06 40 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('*'), 
     ), 
    ); 
} 

,我不能訪問該用戶登錄這些網頁這個角色。這是什麼問題?

回答