You are here

public function GALoginHotpValidation::buildConfigurationForm in Google Authenticator login 8

The configuration form for this validation plugin.

Parameters

\Drupal\Core\Config\Config $config: Config object for tfa settings.

array $state: Form state array determines if this form should be shown.

Return value

array Form array specific for this validation plugin.

File

src/Plugin/TfaValidation/GALoginHotpValidation.php, line 168

Class

GALoginHotpValidation
HOTP validation class for performing HOTP validation.

Namespace

Drupal\ga_login\Plugin\TfaValidation

Code

public function buildConfigurationForm(Config $config, array $state = []) {
  $settings_form['counter_window'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Counter Window'),
    '#default_value' => $this->counterWindow ?: 5,
    '#description' => $this
      ->t('How far ahead from current counter should we check the code.'),
    '#size' => 2,
    '#states' => $state,
    '#required' => TRUE,
  ];
  $settings_form['site_name_prefix'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use site name as OTP QR code name prefix.'),
    '#default_value' => $this->siteNamePrefix,
    '#description' => $this
      ->t('If checked, the site name will be used instead of a static string. This can be useful for multi-site installations.'),
    '#states' => $state,
  ];

  // Hide custom name prefix when site name prefix is selected.
  $state['visible'] += [
    ':input[name="validation_plugin_settings[ga_login_hotp][site_name_prefix]"]' => [
      'checked' => FALSE,
    ],
  ];
  $settings_form['name_prefix'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('OTP QR Code Prefix'),
    '#default_value' => $this->namePrefix ?: 'tfa',
    '#description' => $this
      ->t('Prefix for OTP QR code names. Suffix is account username.'),
    '#size' => 15,
    '#states' => $state,
  ];
  $settings_form['issuer'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Issuer'),
    '#default_value' => $this->issuer,
    '#description' => $this
      ->t('The provider or service this account is associated with.'),
    '#size' => 15,
    '#required' => TRUE,
  ];
  return $settings_form;
}