You are here

function _auth0_generate_authorize_url in Auth0 Single Sign On 7.2

2 calls to _auth0_generate_authorize_url()
auth0_callback in ./auth0.module
User login API callback.
template_preprocess_auth0_lock in ./auth0.module
Preprocess the login widget.

File

./auth0.module, line 938

Code

function _auth0_generate_authorize_url($prompt) {
  $query = array(
    'redirect_uri' => url('auth0/callback', array(
      'absolute' => TRUE,
      'query' => drupal_get_destination(),
    )),
    'connection' => null,
    'response_type' => 'code',
  );

  /* Overwrite values if needed */
  if (is_array($prompt)) {
    $query = array_merge($query, $prompt);
  }

  /* Set the state, if not passed in */
  if (!isset($_SESSION['auth0_session_started'])) {
    $_SESSION['auth0_session_started'] = TRUE;
    drupal_session_start();
  }
  $state = isset($query['state']) ? $query['state'] : drupal_get_token('auth0_state');
  $response_type = $query['response_type'];
  $redirect_uri = $query['redirect_uri'];
  $connection = $query['connection'];
  unset($query['state']);
  unset($query['response_type']);
  unset($query['redirect_uri']);
  unset($query['connection']);
  $additional_params = [];
  $additional_params['scope'] = 'openid profile email';
  $additional_params = array_merge($additional_params, $query);
  $domain = check_plain(variable_get("auth0_domain", ''));
  $client_id = check_plain(variable_get("auth0_client_id", ''));
  $auth0Api = new Authentication($domain, $client_id);
  return $auth0Api
    ->get_authorize_link($response_type, $redirect_uri, $connection, $state, $additional_params);
}