title: Yii Simple RBAC Error
body: <p>I just a newbie in Yii. I have read <a href="http://www.yiiframework.com/wiki/328/simple-rbac/" rel="nofollow">http://www.yiiframework.com/wiki/328/simple-rbac/</a> and followed all instructions there, but I had error User.roles is not defined when I tried to login. Here is my UserIdentity.php</p>
  
  <pre><code>&lt;?php
  class UserIdentity extends CUserIdentity
  {
  private $_id;
  
  public function authenticate()
  {
      $user = User::model()-&gt;findByAttributes(array
              ('username'=&gt;$this-&gt;username));
  
      if($user===null){
          $this-&gt;errorCode=self::ERROR_USERNAME_INVALID;
      }
      else{
          if($user-&gt;password!==$user-&gt;encrypt($this-&gt;password)){
              $this-&gt;errorCode=self::ERROR_PASSWORD_INVALID;
          }
          else{
              $this-&gt;_id = $user-&gt;username;
              $this-&gt;setState('roles', $user-&gt;roles);
              $this-&gt;errorCode=self::ERROR_NONE;
          }
      }
      return !$this-&gt;errorCode;
  }
  
  public function getId(){
      return $this-&gt;_id;
  }
  }
  </code></pre>
  
  <p>And then EWebUser.php</p>
  
  <pre><code>&lt;?php 
  class EWebUser extends CWebUser
  {
      public function checkAccess($operation, $params=array())
      {
          if (empty($this-&gt;id)) {
              // Not identified =&gt; no rights
              return false;
          }
          $role = $this-&gt;getState("roles");
          if ($role === 'admin') {
              return true; // admin role has access to everything
          }
          // allow access if the operation request is the current user's role
          return ($operation === $role);
      }
  }
  </code></pre>
  
  <p>At last accessRules method in UserController.php</p>
  
  <pre><code>public function accessRules()
  {
        .....
      return array(
          array('allow', // allow admin user to perform 'admin' and 'delete' actions
              'actions'=&gt;array('admin','delete'),
              //'users'=&gt;array('admin'),
              'roles'=&gt;array('admin'),
      .....
      );
  }
  </code></pre>
  
  <p>I hope anyone can help me solve this problwm, thank you very much</p>