title: Yii, custom WebUser property
body: <p>AFAIK I do right</p>
  
  <p>UserIdentity</p>
  
  <pre><code>class UserIdentity extends CUserIdentity
  {
      const ERROR_NOT_ACTIVE = 111;
      //
      private $role;
      private $_id;
  
      /**
       * @return bool
       */
      public function authenticate()
      {
          $oUser = User::model()-&gt;find('LOWER(login) = ?', array(strtolower($this-&gt;username)));
  
          if ($oUser === null) {
              $this-&gt;errorCode = self::ERROR_USERNAME_INVALID;
          } else {
              // wrong password
              if (!$oUser-&gt;validatePassword($this-&gt;password)) {
                  $this-&gt;errorCode = self::ERROR_PASSWORD_INVALID;
              } // user not activated by admin
              elseif ($oUser-&gt;active) {
                  $this-&gt;_id = $oUser-&gt;id;
                  $this-&gt;role = $oUser-&gt;role;
                  $this-&gt;username = $oUser-&gt;login;
                  $this-&gt;errorCode = self::ERROR_NONE;
              } // user valid and activated
              else {
                  $this-&gt;errorCode = self::ERROR_NOT_ACTIVE;
              }
          }
  
          return $this-&gt;errorCode == self::ERROR_NONE;
      }
  
      /**
       * @return mixed|string
       */
      public function getID()
      {
          return $this-&gt;_id;
      }
  
      public function getRole()
      {
          return $this-&gt;role;
      }
  }
  </code></pre>
  
  <p>WebUser</p>
  
  <pre><code>class WebUser extends CWebUser
  {
      /**
       * @return boolean
       */
      public function isAdmin()
      {
          var_dump($this-&gt;getState('role'));
          return ($this-&gt;getState('role') === User::ROLE_ADMIN);
      }
  }
  </code></pre>
  
  <p>config</p>
  
  <pre><code>'components' =&gt; array(
          'user' =&gt; array(
              // enable cookie-based authentication
              'class' =&gt; 'WebUser',
  </code></pre>
  
  <p>But in WebUser there is no role property at all. Any other variations to get it gives error. Question is how to give any data to WebUser from UserIdentity (once on login), but not using additional queries to db (in WebUser). </p>