src/Authenticator/SessionAuthenticator.php
public function authenticate(ServerRequestInterface $request, ResponseInterface $response)
    {
        $sessionKey = $this->getConfig('sessionKey');
        $session = $request->getAttribute('session');
        $user = $session->read($sessionKey);

        if (empty($user)) {
            return new Result(null, Result::FAILURE_IDENTITY_NOT_FOUND);
        }

        if ($this->getConfig('identify') === true) {
            $credentials = [];
            foreach ($this->getConfig('fields') as $key => $field) {
                $credentials[$key] = $user[$field];
            }
            $user = $this->_identifier->identify($credentials);

            if (empty($user)) {
                return new Result(null, Result::FAILURE_CREDENTIALS_INVALID);
            }
        }

        if (!($user instanceof ArrayAccess)) {
            $user = new ArrayObject($user);
        }

        return new Result($user, Result::SUCCESS);
    }
public function authenticate(ServerRequestInterface $request, ResponseInterface $response)
    {
        $sessionKey = $this->getConfig('sessionKey');
        $session = $request->getAttribute('session');
        $user = $session->read($sessionKey);

        if (empty($user)) {
            return new Result(null, Result::FAILURE_IDENTITY_NOT_FOUND);
        }

        if ($this->getConfig('identify') === true) {
            $credentials = [];
            foreach ($this->getConfig('fields') as $key => $field) {
                $credentials[$key] = $user[$field];
            }
            $user = $this->_identifier->identify($credentials);

            if (empty($user)) {
                return new Result(null, Result::FAILURE_CREDENTIALS_INVALID);
            }
        }

        if (!($user instanceof ArrayAccess)) {
            $user = new ArrayObject($user);
        }

        return new Result($user, Result::SUCCESS);
    }
public function authenticate ( ServerRequestInterface $ request , ResponseInterface $ response ) { $ sessionKey = $ this -> getConfig ( 'sessionKey' ) ; $ session = $ request -> getAttribute ( 'session' ) ; $ user = $ session -> read ( $ sessionKey ) ; if ( empty ( $ user ) ) { return new Result ( null , Result :: FAILURE_IDENTITY_NOT_FOUND ) ; } if ( $ this -> getConfig ( 'identify' ) === true ) { $ credentials = [ ] ; foreach ( $ this -> getConfig ( 'fields' ) as $ key => $ field ) { $ credentials [ $ key ] = $ user [ $ field ] ; } $ user = $ this -> _identifier -> identify ( $ credentials ) ; if ( empty ( $ user ) ) { return new Result ( null , Result :: FAILURE_CREDENTIALS_INVALID ) ; } } if ( ! ( $ user instanceof ArrayAccess ) ) { $ user = new ArrayObject ( $ user ) ; } return new Result ( $ user , Result :: SUCCESS ) ; }
Authenticate a user using session data.

@param \Psr\Http\Message\ServerRequestInterface $request The request to authenticate with.
@param \Psr\Http\Message\ResponseInterface $response The response to add headers to.
@return \Authentication\Authenticator\ResultInterface
Authenticate a user using session data .