src/logic/Impersonator.php
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());
    }
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());
    }
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 ( ) ) ; }
Method should be called when authentication succeeded.
@param HiamClient $client
Method should be called when authentication succeeded .