You are here

public function MobileNumberTfa::validateForm in Mobile Number 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/TfaValidation/MobileNumberTfa.php \Drupal\mobile_number\Plugin\TfaValidation\MobileNumberTfa::validateForm()

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/MobileNumberTfa.php, line 115
MobileNumberTfa.php

Class

MobileNumberTfa
Class MobileNumberTfa is a validation and sending plugin for TFA.

Namespace

Drupal\mobile_number\Plugin\TfaValidation

Code

public function validateForm(array $form, FormStateInterface $form_state) {

  // If operation is resend then do not attempt to validate code.
  if ($form_state['values']['op'] === $form_state['values']['resend']) {
    return TRUE;
  }
  elseif (!$this
    ->verifyCode($form_state['values']['code'])) {
    $this->errorMessages['code'] = t('Invalid code.');
    return FALSE;
  }
  else {
    return TRUE;
  }
}