admin logged in as customer

hello my friends,

I need insert one button in my module admin which come in account user.

but my component cuserIdentity of the module return error Property "CWebUser.logNivel" is not defined.

In my module i created a component and a module to work with this login.

View my controller:




//function get id user

public function actionLogarEmpresa($id){

            //new model to this login

            $model=new LoginForm2;

            

            $eKey = Yii::app()->getSecurityManager()->getEncryptionKey();

            

            $userEmpresa = Usuarios::model()->findByPk($id);

            

           $model->username = $userEmpresa->email;

           $model->password =  Yii::app()->getSecurityManager()->decrypt(utf8_decode($userEmpresa->senha), $eKey );

	   $model->rememberMe = 0;

            

            // new function to this login

            if($model->sublogin()){

                    //retirect to page of the user

                 $this->redirect(array('/adicionarVaga'));

            }else{

                echo CHtml::errorSummary($model);

                echo "<p>usuario = ".$model->username." senha = ".$model->password."</p>";

            }

            

        }

View CUserIdentity the my module:


class entrarConta extends CUserIdentity

{

    private $usuario = null;

    private $eKey;

	

	public function subauthenticate()

	{

 

            $this->eKey = Yii::app()->getSecurityManager()->getEncryptionKey();

            if(strpos($this->username,"@")){

                $this->usuario=Usuarios::model()->findByAttributes(array('email'=>$this->username));

                

            }

            

            if($this->usuario===null){

                $this->errorCode=self::ERROR_USERNAME_INVALID;

            }else{

                if(Yii::app()->getSecurityManager()->decrypt(utf8_decode($this->usuario->senha), $this->eKey )!= $this->password){

                    $this->errorCode=self::ERROR_PASSWORD_INVALID; 

                }else{

                    /**

                     ******This Return Error **************/

                    Yii::app()->user->setState('logNivel', $this->usuario->nivel);

                    Yii::app()->user->setState('cadastro_user', $this->usuario->id_cadastro);

                    $this->errorCode=self::ERROR_NONE;

		return !$this->errorCode;

                }

            }

            

            

	}

            

            

}

I think it "setState" not use out module.

I managed to solve!

In main created a stateKeyPrefix = ‘xxxx’.

in component modules custom i set:

Yii::app()->user->setStateKeyPrefix(‘xxxx’);

this works ;)