You are here

public function AuthController::login in Auth0 Single Sign On 8

Same name and namespace in other branches
  1. 8.2 src/Controller/AuthController.php \Drupal\auth0\Controller\AuthController::login()

Handles the login page override.

1 string reference to 'AuthController::login'
auth0.routing.yml in ./auth0.routing.yml
auth0.routing.yml

File

src/Controller/AuthController.php, line 77

Class

AuthController
Controller routines for auth0 authentication.

Namespace

Drupal\auth0\Controller

Code

public function login() {
  global $base_root;
  $config = \Drupal::service('config.factory')
    ->get('auth0.settings');
  $lockExtraSettings = $config
    ->get('auth0_lock_extra_settings');
  if (trim($lockExtraSettings) == "") {
    $lockExtraSettings = "{}";
  }

  /**
   * If supporting SSO, redirect to the hosted login page for authorization
   */
  if ($this->redirect_for_sso == TRUE) {
    $prompt = 'none';
    return new TrustedRedirectResponse($this
      ->buildAuthorizeUrl($prompt));
  }

  /* Not doing SSO, so show login page */
  return array(
    '#theme' => 'auth0_login',
    '#domain' => $config
      ->get('auth0_domain'),
    '#clientID' => $config
      ->get('auth0_client_id'),
    '#state' => $this
      ->getNonce(),
    '#showSignup' => $config
      ->get('auth0_allow_signup'),
    '#widgetCdn' => $config
      ->get('auth0_widget_cdn'),
    '#loginCSS' => $config
      ->get('auth0_login_css'),
    '#lockExtraSettings' => $lockExtraSettings,
    '#callbackURL' => "{$base_root}/auth0/callback",
  );
}