You are here

public function Oauth2AuthorizeForm::submitForm in Simple OAuth (OAuth2) & OpenID Connect 8.3

Same name and namespace in other branches
  1. 8.2 simple_oauth_extras/src/Controller/Oauth2AuthorizeForm.php \Drupal\simple_oauth_extras\Controller\Oauth2AuthorizeForm::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

simple_oauth_extras/src/Controller/Oauth2AuthorizeForm.php, line 216

Class

Oauth2AuthorizeForm
Authorize form.

Namespace

Drupal\simple_oauth_extras\Controller

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  if ($auth_request = $form_state
    ->get('auth_request')) {
    $can_grant_codes = $this
      ->currentUser()
      ->hasPermission('grant simple_oauth codes');
    $redirect_response = Oauth2AuthorizeController::redirectToCallback($auth_request, $this->server, $this
      ->currentUser(), (bool) $form_state
      ->getValue('submit') && $can_grant_codes, (bool) $this->configFactory
      ->get('simple_oauth.settings')
      ->get('remember_clients'), $this->knownClientRepository);
    $form_state
      ->setResponse($redirect_response);
  }
}