You are here

public function UserKeyAuthForm::submitForm in Key auth 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

src/Form/UserKeyAuthForm.php, line 156

Class

UserKeyAuthForm
Class UserKeyAuthForm.

Namespace

Drupal\key_auth\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Generate a new key.
  User::load($form['#uid'])
    ->set('api_key', $this->keyAuth
    ->generateKey())
    ->save();

  // Alert the user.
  $this
    ->messenger()
    ->addMessage($this
    ->t('A new key has been generated.'));
}