How to extend CWebUser

I want to extend CWebUser. I want to give some users (admins) the ability to switch personality and become a different user. That looks simple enough:



class MyWebUser extends CWebUser {


    public function changeIdentity($new_id) {


        $this->setState('old_id', $this->_id);


        $this->_id = $new_id


    }


}

The PROBLEM I have is that I don't know how to make my UserIdentity class return a MyWebUser object instead of a regular CWebUser object. How can I do that?

I remember now that the UserIdentity class doesn't return a CWebUser but instead we do: Yii::app()->user->login($identity);

But I still don't know how I can extend CWebUser into a new class called MyWebUser. I guess I could just edit CWebUser directly, but I'm not sure if that's "recommended".

It's a config issue. Add the following (or modify it if you already have a class there) to the user-array:

    'class'=>'application.components.MyWebUser'

Thanks!

You know what I just realized? CWebUser already has a changeIdentity() method. I'd better figure out how that one works. Maybe I should just reuse that.