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);