protected function _handleCallbackAction(ServerRequest $request, Response $response)
    {
        $this->_setupModelInstances();

        $config = $this->getConfig();
        $providerName = $request->getParam('provider');

        $profile = $this->_getProfile($providerName, $request);
        if (!$profile) {
            return $response->withLocation(
                Router::url($config['loginUrl'], true) . '?error=' . $this->_error
            );
        }

        $user = $this->_getUser($profile);
        if (!$user) {
            return $response->withLocation(
                Router::url($config['loginUrl'], true) . '?error=' . $this->_error
            );
        }

        $user->unsetProperty($config['fields']['password']);

        if (!$config['userEntity']) {
            $user = $user->toArray();
        }

        $event = $this->dispatchEvent(self::EVENT_AFTER_IDENTIFY, ['user' => $user]);
        $result = $event->getResult();
        if ($result !== null) {
            $user = $event->getResult();
        }

        $request->getSession()->write($config['sessionKey'], $user);

        return $response->withLocation(
            Router::url($this->_getRedirectUrl($request), true)
        );
    }
protected function _handleCallbackAction(ServerRequest $request, Response $response)
    {
        $this->_setupModelInstances();

        $config = $this->getConfig();
        $providerName = $request->getParam('provider');

        $profile = $this->_getProfile($providerName, $request);
        if (!$profile) {
            return $response->withLocation(
                Router::url($config['loginUrl'], true) . '?error=' . $this->_error
            );
        }

        $user = $this->_getUser($profile);
        if (!$user) {
            return $response->withLocation(
                Router::url($config['loginUrl'], true) . '?error=' . $this->_error
            );
        }

        $user->unsetProperty($config['fields']['password']);

        if (!$config['userEntity']) {
            $user = $user->toArray();
        }

        $event = $this->dispatchEvent(self::EVENT_AFTER_IDENTIFY, ['user' => $user]);
        $result = $event->getResult();
        if ($result !== null) {
            $user = $event->getResult();
        }

        $request->getSession()->write($config['sessionKey'], $user);

        return $response->withLocation(
            Router::url($this->_getRedirectUrl($request), true)
        );
    }
protected function _handleCallbackAction ( ServerRequest $ request , Response $ response ) { $ this -> _setupModelInstances ( ) ; $ config = $ this -> getConfig ( ) ; $ providerName = $ request -> getParam ( 'provider' ) ; $ profile = $ this -> _getProfile ( $ providerName , $ request ) ; if ( ! $ profile ) { return $ response -> withLocation ( Router :: url ( $ config [ 'loginUrl' ] , true ) . '?error=' . $ this -> _error ) ; } $ user = $ this -> _getUser ( $ profile ) ; if ( ! $ user ) { return $ response -> withLocation ( Router :: url ( $ config [ 'loginUrl' ] , true ) . '?error=' . $ this -> _error ) ; } $ user -> unsetProperty ( $ config [ 'fields' ] [ 'password' ] ) ; if ( ! $ config [ 'userEntity' ] ) { $ user = $ user -> toArray ( ) ; } $ event = $ this -> dispatchEvent ( self :: EVENT_AFTER_IDENTIFY , [ 'user' => $ user ] ) ; $ result = $ event -> getResult ( ) ; if ( $ result !== null ) { $ user = $ event -> getResult ( ) ; } $ request -> getSession ( ) -> write ( $ config [ 'sessionKey' ] , $ user ) ; return $ response -> withLocation ( Router :: url ( $ this -> _getRedirectUrl ( $ request ) , true ) ) ; }
Handle callback action.

@param \Cake\Http\ServerRequest $request The request.
@param \Cake\Http\Response $response The response.

@return \Cake\Http\Response A response.
Handle callback action .