Access To Useridentity From Controller

Hi. In my UserIdentity I have function which is updating user state. I want execute it in controller. I tried


UserIdentity::stateUpdate()

but don’t working. So how to get to UserIdentity from controller?

why you need to access the function in controller?

why you need to access the function in controller? in case if you want to update the user status after login extend to cwebuser and override the afterLogin( ) to fit ur needs

After passing the UserIdentity object to WebUser.login() while logging in it’s not saved anywhere and it’s not available in next requests. You need to recreate it each time you need it.

Because when logging in it’s created using login and password you will probably have to add a method to it to create it from currently logged in user id. Or just add it to the WebUser class.

I made user level system follow this article: http://www.yiiframework.com/wiki/474/implementing-a-flat-user-access-system/

Solved:


$model = $this->loadModel(Yii::app()->user->id, 'User'); 

Yii::app()->user->setState('level',$model->level);