public function GALoginHotpValidation::validateForm in Google Authenticator login 8
Validate form.
Parameters
array $form: The configuration form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
bool Whether form passes validation or not
Overrides TfaValidationInterface::validateForm
File
- src/
Plugin/ TfaValidation/ GALoginHotpValidation.php, line 216
Class
- GALoginHotpValidation
- HOTP validation class for performing HOTP validation.
Namespace
Drupal\ga_login\Plugin\TfaValidationCode
public function validateForm(array $form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
if (!$this
->validate($values['code'])) {
$this->errorMessages['code'] = $this
->t('Invalid application code. Please try again.');
if ($this->alreadyAccepted) {
$form_state
->clearErrors();
$this->errorMessages['code'] = $this
->t('Invalid code, it was recently used for a login. Please try a new code.');
}
return FALSE;
}
else {
// Store accepted code to prevent replay attacks.
$this
->storeAcceptedCode($values['code']);
return TRUE;
}
}