You are here

class TfaBasicSmsSetup in TFA Basic plugins 7

Class TfaBasicSmsSetup

Hierarchy

Expanded class hierarchy of TfaBasicSmsSetup

File

includes/tfa_sms.inc, line 185

View source
class TfaBasicSmsSetup extends TfaBasicSms implements TfaSetupPluginInterface {
  public function __construct(array $context, $mobile_number, $client) {
    parent::__construct($context, $mobile_number, $client);
  }
  public function begin() {
    if (empty($this->code)) {
      $this->code = $this
        ->generate();
      if (!$this
        ->sendCode($this->code)) {

        // @todo decide on error text
        $this->errorMessages[''] = t('Unable to deliver code to that number.');
      }
    }
  }

  /**
   * @copydoc TfaSetupPluginInterface::getSetupForm()
   */
  public function getSetupForm(array $form, array &$form_state) {
    $form['sms_code'] = array(
      '#type' => 'textfield',
      '#title' => t('Verification Code'),
      '#required' => TRUE,
      '#description' => t('Enter @length-character code sent to your device.', array(
        '@length' => $this->codeLength,
      )),
    );
    if (module_exists('elements')) {
      $form['sms_code']['#type'] = 'numberfield';
    }
    $form['actions']['verify'] = array(
      '#type' => 'submit',
      '#value' => t('Verify and save'),
    );
    return $form;
  }

  /**
   * @copydoc TfaSetupPluginInterface::validateSetupForm()
   */
  public function validateSetupForm(array $form, array &$form_state) {
    if (!$this
      ->validate($form_state['values']['sms_code'])) {
      $this->errorMessages['sms_code'] = t('Invalid code. Please try again.');
      return FALSE;
    }
    else {
      return TRUE;
    }
  }

  /**
   * @copydoc TfaSetupPluginInterface::submitSetupForm()
   */
  public function submitSetupForm(array $form, array &$form_state) {

    // No submission handling required.
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TfaBasePlugin::$code protected property TFA code.
TfaBasePlugin::$codeLength protected property Code Length.
TfaBasePlugin::$context protected property Context of current TFA process.
TfaBasePlugin::$encryptionKey protected property Encryption key.
TfaBasePlugin::$errorMessages protected property Error messages.
TfaBasePlugin::$isValid protected property Code is valid.
TfaBasePlugin::CRYPT_VERSION constant
TfaBasePlugin::decrypt protected function Decrypt a encrypted string.
TfaBasePlugin::decryptLegacyDataWithMcrypt protected function Decrypt using the deprecated Mcrypt extension.
TfaBasePlugin::decryptLegacyDataWithOpenSSL protected function Use OpenSSL to decrypt data that was originally encrypted with Mcrypt.
TfaBasePlugin::encrypt protected function Encrypt a plaintext string.
TfaBasePlugin::encryptWithMcrypt protected function Encrypt using the deprecated Mcrypt extension.
TfaBasePlugin::getErrorMessages public function Get error messages suitable for form_set_error().
TfaBasePlugin::timingSafeEquals private function A timing safe equals comparison.
TfaBasePlugin::validate protected function Validate code.
TfaBasicSms::$client protected property
TfaBasicSms::$mobileNumber protected property
TfaBasicSms::$twilioNumber protected property
TfaBasicSms::generate protected function Generate a random string of characters of length $this->codeLength. Overrides TfaBasePlugin::generate
TfaBasicSms::getAccountNumber protected function
TfaBasicSms::getForm public function Get TFA process form from plugin. Overrides TfaValidationPluginInterface::getForm
TfaBasicSms::getPluginContext public function Return context for this plugin.
TfaBasicSms::ready public function Determine if the plugin can run for the current TFA context. Overrides TfaBasePlugin::ready
TfaBasicSms::sendCode protected function Send the code via the client.
TfaBasicSms::submitForm public function Submit form. Overrides TfaBasePlugin::submitForm
TfaBasicSms::validateForm public function Validate form. Overrides TfaValidationPluginInterface::validateForm
TfaBasicSmsSetup::begin public function TFA process begin. Overrides TfaBasicSms::begin
TfaBasicSmsSetup::getSetupForm public function @copydoc TfaSetupPluginInterface::getSetupForm() Overrides TfaSetupPluginInterface::getSetupForm
TfaBasicSmsSetup::submitSetupForm public function @copydoc TfaSetupPluginInterface::submitSetupForm() Overrides TfaSetupPluginInterface::submitSetupForm
TfaBasicSmsSetup::validateSetupForm public function @copydoc TfaSetupPluginInterface::validateSetupForm() Overrides TfaSetupPluginInterface::validateSetupForm
TfaBasicSmsSetup::__construct public function Plugin constructor. Overrides TfaBasicSms::__construct