In protected/models/useridentity.php I have
class UserIdentity extends CUserIdentity
{
private $_id = 0;
public function authenticate()
{
$user = User::model()->findByAttributes(array('username'=>$this->username));
if ($user===null)
{
// No user found!
$this->errorCode=self::ERROR_USERNAME_INVALID;
}
// md5 encryption
else if ($user->password !== md5($this->password) )
{
// Invalid password!
$this->errorCode=self::ERROR_PASSWORD_INVALID;
}
else
{
// No error
Yii::app()->setLanguage($user->locale->code);
$this->setState('superuser', $user->superuser);
$this->_id=$user->id;
$this->errorCode=self::ERROR_NONE;
}
return !$this->errorCode;
}
public function getId()
{
return $this->_id;
}
}
If a user hasn’t logged in, then Yii::app()->user->superuser property isn’t available. Whats the best way around this?
Many thanks, Russ