I'm building an authentication module for my application and I don't quite understand the relation between CWebUser
and CUserIdentity
.
To set the user id to Yii::app()->user->id
I have to do that in my UserIdentity
class and create a method:
public function getId() {
return $this->_id;
}
But to set isAdmin
to Yii::app()->user->isAdmin
I have to create a method in my WebUser
class:
function getIsAdmin() {
$user = $this->loadUser(Yii::app()->user->id);
return intval($user->user_level_id) == AccountModule::USER_LEVEL_ADMIN;
}
Why can't I just create the methods the UserIdentity
class? What is the division of labour here?