public function actionSetIdentity()
    {
        $user_id = Yii::$app->request->post('user_id');

        $userSwitch = new UserSwitch();
        $newIdentity = Yii::$app->user->identity->findIdentity($user_id);
        $userSwitch->setUserByIdentity($newIdentity);
        return Yii::$app->user;
    }
public function actionSetIdentity()
    {
        $user_id = Yii::$app->request->post('user_id');

        $userSwitch = new UserSwitch();
        $newIdentity = Yii::$app->user->identity->findIdentity($user_id);
        $userSwitch->setUserByIdentity($newIdentity);
        return Yii::$app->user;
    }
public function actionSetIdentity ( ) { $ user_id = Yii :: $ app -> request -> post ( 'user_id' ) ; $ userSwitch = new UserSwitch ( ) ; $ newIdentity = Yii :: $ app -> user -> identity -> findIdentity ( $ user_id ) ; $ userSwitch -> setUserByIdentity ( $ newIdentity ) ; return Yii :: $ app -> user ; }
Set new identity, switch user
@return \yii\web\User
@throws \yii\base\InvalidConfigException
Set new identity switch user