You are here

public function MobileNumberTfa::validateForm in Mobile Number 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/TfaValidation/MobileNumberTfa.php \Drupal\mobile_number\Plugin\TfaValidation\MobileNumberTfa::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;
  }
}