You are here

public function UsersKeyForm::submitForm in JSON Web Token Authentication (JWT) 8

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

modules/users_jwt/src/Form/UsersKeyForm.php, line 155

Class

UsersKeyForm
Class UsersKeyForm.

Namespace

Drupal\users_jwt\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $key = $form_state
    ->getValue('key');
  $is_new = $form_state
    ->getValue('is_new');
  if ($is_new) {
    $key->id = trim($form_state
      ->getValue('id'));
  }
  $this->keyRepository
    ->saveKey($key->uid, $key->id, $form_state
    ->getValue('alg'), $form_state
    ->getValue('pubkey'));
  $this
    ->messenger()
    ->addStatus('Saved key %key_id', [
    '%key_id' => $key->id,
  ]);
  $form_state
    ->setRedirect('users_jwt.key_list', [
    'user' => $key->uid,
  ]);
}