You are here

public function GALoginTotpSetup::validateSetupForm in Google Authenticator login 8

Validate the setup data.

Parameters

array $form: The configuration form array.

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

Return value

bool Whether or not form passes validation.

Overrides TfaSetupInterface::validateSetupForm

File

src/Plugin/TfaSetup/GALoginTotpSetup.php, line 113

Class

GALoginTotpSetup
TOTP setup class to setup TOTP validation.

Namespace

Drupal\ga_login\Plugin\TfaSetup

Code

public function validateSetupForm(array $form, FormStateInterface $form_state) {
  if (!$this
    ->validate($form_state
    ->getValue('code'))) {
    $this->errorMessages['code'] = $this
      ->t('Invalid application code. Please try again.');
    return FALSE;
  }
  $this
    ->storeAcceptedCode($form_state
    ->getValue('code'));
  return TRUE;
}