You are here

class TfaTestFallback in Two-factor Authentication (TFA) 7.2

Class TfaTestFallback.

Hierarchy

Expanded class hierarchy of TfaTestFallback

1 string reference to 'TfaTestFallback'
tfa_test_tfa_api in tests/tfa_test.module
Implements hook_tfa_api().

File

tests/includes/tfa_test.fallback.inc, line 11
Tests for the TfaValidationPluginInterface.

View source
class TfaTestFallback extends TfaBasePlugin implements TfaValidationPluginInterface {

  /**
   * Constructor.
   */
  public function __construct(array $context = array()) {
    parent::__construct($context);
    $this->code = 'FAILSAFE';
  }

  /**
   * {@inheritdoc}
   */
  public function getForm(array $form, array &$form_state) {
    $form['recover'] = array(
      '#type' => 'textfield',
      '#title' => t('Enter recovery code'),
      '#required' => TRUE,
    );
    $form['login'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array $form, array &$form_state) {
    if (!parent::validate($form_state['values']['recover'])) {
      $this->errorMessages['code'] = t('Invalid recovery code');
      return FALSE;
    }
    else {
      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::generate protected function Generate a random string of characters of length $this->codeLength.
TfaBasePlugin::getErrorMessages public function Get error messages suitable for form_set_error().
TfaBasePlugin::ready public function Determine if the plugin can run for the current TFA context. 2
TfaBasePlugin::submitForm public function Submit form. 1
TfaBasePlugin::timingSafeEquals private function A timing safe equals comparison.
TfaBasePlugin::validate protected function Validate code.
TfaTestFallback::getForm public function Get TFA process form from plugin. Overrides TfaValidationPluginInterface::getForm
TfaTestFallback::validateForm public function Validate form. Overrides TfaValidationPluginInterface::validateForm
TfaTestFallback::__construct public function Constructor. Overrides TfaBasePlugin::__construct