public function GALoginTotpValidation::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/ GALoginTotpValidation.php, line 220
Class
- GALoginTotpValidation
- TOTP validation class for performing TOTP 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;
}
}