Hybrid_Auth::getProviders PHP Method

getProviders() public static method

array( 'Facebook' => array( 'connected' => true ) )
public static getProviders ( ) : array
return array
    public static function getProviders()
    {
        $idps = array();
        foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
            if ($params['enabled']) {
                $idps[$idpid] = array('connected' => false);
                if (Hybrid_Auth::isConnectedWith($idpid)) {
                    $idps[$idpid]['connected'] = true;
                }
            }
        }
        return $idps;
    }

Usage Example

Esempio n. 1
0
        unset($cpf_check[0]);
        foreach ($cpf_check as $cpf_error) {
            $registration_errors[] = $cpf_error;
        }
    }

    // validate HybridAuth provider and user id and check if it's already in the db (shouldn't be
    // because the user would be logged in the system rather than redirected here)
    // check if there are any available alternative providers for authentication
    if (!empty($_POST['provider_id'])) {
        require_once 'modules/auth/methods/hybridauth/config.php';
        require_once 'modules/auth/methods/hybridauth/Hybrid/Auth.php';
        $config = get_hybridauth_config();

        $hybridauth = new Hybrid_Auth( $config );
        $allProviders = $hybridauth->getProviders();
        $provider = '';
        $warning = '';

        // check if $_POST['provider'] is valid and enabled
        if (count($allProviders) && array_key_exists(ucfirst($_POST['provider']), $allProviders)) {
            $provider = strtolower($_POST['provider']);
        }
        if (!empty($_POST['provider_id']) && !empty($provider)) {
            // if !empty($provider), it means the provider is existent and valid - it's checked above
            try {
                // create an instance for Hybridauth with the configuration file path as parameter
                $hybridauth = new Hybrid_Auth($config);

                // try to authenticate the selected $provider
                $adapter = $hybridauth->authenticate($provider);