public function impersonateUser(HiamClient $client)
    {
        $attributes = $client->getUserAttributes();
        $identity = new User();
        foreach ($identity->attributes() as $k) {
            if (isset($attributes[$k])) {
                $identity->{$k} = $attributes[$k];
            }
        }
        if ($this->user->getId() === $identity->getId()) {
            return;
        }

        $identity->save();
        $this->session->set('__realId', $this->user->getId());
        $this->user->setIdentity($identity);
        $this->session->set($this->user->idParam, $this->user->getId());
    }