You are here

public function MobileNumberTfa::submitForm in Mobile Number 7

Submit form callback.

Overrides TfaBasePlugin::submitForm

File

src/MobileNumberTfa.php, line 125
Contains MobileNumberTfa.

Class

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

Code

public function submitForm(array $form, array &$form_state) {

  // Resend code if pushed.
  if ($form_state['values']['op'] === $form_state['values']['resend']) {
    if (!$this->mobileNumber
      ->checkFlood('sms')) {
      drupal_set_message(t('Too many verification code requests, please try again shortly.'), 'error');
    }
    elseif (!$this
      ->sendCode()) {
      drupal_set_message(t('Unable to deliver the code. Please contact support.'), 'error');
    }
    else {
      drupal_set_message(t('Code resent'));
    }
    return FALSE;
  }
  else {
    return parent::submitForm($form, $form_state);
  }
}