You are here

function _hybridauth_window_auth in HybridAuth Social Login 6.2

Same name and namespace in other branches
  1. 7.2 hybridauth.pages.inc \_hybridauth_window_auth()
1 call to _hybridauth_window_auth()
hybridauth_window_start in ./hybridauth.pages.inc

File

./hybridauth.pages.inc, line 81

Code

function _hybridauth_window_auth($hybridauth, $provider_id) {
  $params = array(
    'hauth_return_to' => url('hybridauth/window/' . $provider_id, array(
      'absolute' => TRUE,
      'query' => drupal_get_destination(),
    )),
  );
  if (isset($_GET['openid_identifier'])) {
    $params['openid_identifier'] = $_GET['openid_identifier'];
  }
  try {
    $adapter = $hybridauth
      ->authenticate($provider_id, $params);
    $profile = (array) $adapter
      ->getUserProfile();
  } catch (Exception $e) {
    $redirect = TRUE;
    switch ($e
      ->getCode()) {
      case 5:

        // Authentification failed. The user has canceled the authentication or the provider refused the connection.
        $redirect = FALSE;
        break;
      case 0:

      // Unspecified error
      case 1:

      // Hybridauth configuration error
      case 2:

      // Provider not properly configured
      case 3:

      // Unknown or disabled provider
      case 4:

      // Missing provider application credentials (your application id, key or secret)
      case 6:

      // User profile request failed
      case 7:

      // User not connected to the provider
      case 8:

      // Provider does not support this feature
      default:

        // Report the error and log it.
        drupal_set_message(t('There was an error processing your request.'), 'error');
    }

    //watchdog_exception('hybridauth', $e);
    watchdog('hybridauth', $e
      ->getMessage(), array(), WATCHDOG_ERROR);
    _hybridauth_window_close($redirect);
  }
  $profile['provider'] = $provider_id;

  // Invoke hook_hybridauth_profile_alter().
  drupal_alter('hybridauth_profile', $profile);

  // Process Drupal authentication.
  _hybridauth_window_process_auth($profile);
}