You are here

public function TfaTotp::validateForm in TFA Basic plugins 7

@copydoc TfaValidationPluginInterface::validateForm()

Overrides TfaValidationPluginInterface::validateForm

File

includes/tfa_totp.inc, line 73
classes for tfa_totp

Class

TfaTotp
Class TfaTotp

Code

public function validateForm(array $form, array &$form_state) {
  if (!$this
    ->validate($form_state['values']['code'])) {
    $this->errorMessages['code'] = t('Invalid application code. Please try again.');
    if ($this->alreadyAccepted) {
      $this->errorMessages['code'] = t('Invalid code, it was recently used for a login. Please wait for the application to generate a new code.');
    }
    return FALSE;
  }
  else {

    // Store accepted code to prevent replay attacks.
    $this
      ->storeAcceptedCode($form_state['values']['code']);
    return TRUE;
  }
}