You are here

public function OpenIDConnectLoginForm::submitForm in OpenID Connect / OAuth client 2.x

Same name and namespace in other branches
  1. 8 src/Form/OpenIDConnectLoginForm.php \Drupal\openid_connect\Form\OpenIDConnectLoginForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/OpenIDConnectLoginForm.php, line 97

Class

OpenIDConnectLoginForm
Provides the OpenID Connect login form.

Namespace

Drupal\openid_connect\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->session
    ->saveDestination();
  $client_name = $form_state
    ->getTriggeringElement()['#name'];

  /** @var \Drupal\openid_connect\OpenIDConnectClientEntityInterface $client */
  $client = $this->entityTypeManager
    ->getStorage('openid_connect_client')
    ->loadByProperties([
    'id' => $client_name,
  ])[$client_name];
  $plugin = $client
    ->getPlugin();
  $scopes = $this->claims
    ->getScopes($plugin);
  $this->session
    ->saveOp('login');
  $response = $plugin
    ->authorize($scopes);
  $form_state
    ->setResponse($response);
}