class TfaBasicSmsSetup in TFA Basic plugins 7
Class TfaBasicSmsSetup
Hierarchy
- class \TfaBasePlugin
- class \TfaBasicSms implements TfaSendPluginInterface, TfaValidationPluginInterface
- class \TfaBasicSmsSetup implements TfaSetupPluginInterface
- class \TfaBasicSms implements TfaSendPluginInterface, TfaValidationPluginInterface
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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TfaBasePlugin:: |
protected | property | TFA code. | |
TfaBasePlugin:: |
protected | property | Code Length. | |
TfaBasePlugin:: |
protected | property | Context of current TFA process. | |
TfaBasePlugin:: |
protected | property | Encryption key. | |
TfaBasePlugin:: |
protected | property | Error messages. | |
TfaBasePlugin:: |
protected | property | Code is valid. | |
TfaBasePlugin:: |
constant | |||
TfaBasePlugin:: |
protected | function | Decrypt a encrypted string. | |
TfaBasePlugin:: |
protected | function | Decrypt using the deprecated Mcrypt extension. | |
TfaBasePlugin:: |
protected | function | Use OpenSSL to decrypt data that was originally encrypted with Mcrypt. | |
TfaBasePlugin:: |
protected | function | Encrypt a plaintext string. | |
TfaBasePlugin:: |
protected | function | Encrypt using the deprecated Mcrypt extension. | |
TfaBasePlugin:: |
public | function | Get error messages suitable for form_set_error(). | |
TfaBasePlugin:: |
private | function | A timing safe equals comparison. | |
TfaBasePlugin:: |
protected | function | Validate code. | |
TfaBasicSms:: |
protected | property | ||
TfaBasicSms:: |
protected | property | ||
TfaBasicSms:: |
protected | property | ||
TfaBasicSms:: |
protected | function |
Generate a random string of characters of length $this->codeLength. Overrides TfaBasePlugin:: |
|
TfaBasicSms:: |
protected | function | ||
TfaBasicSms:: |
public | function |
Get TFA process form from plugin. Overrides TfaValidationPluginInterface:: |
|
TfaBasicSms:: |
public | function | Return context for this plugin. | |
TfaBasicSms:: |
public | function |
Determine if the plugin can run for the current TFA context. Overrides TfaBasePlugin:: |
|
TfaBasicSms:: |
protected | function | Send the code via the client. | |
TfaBasicSms:: |
public | function |
Submit form. Overrides TfaBasePlugin:: |
|
TfaBasicSms:: |
public | function |
Validate form. Overrides TfaValidationPluginInterface:: |
|
TfaBasicSmsSetup:: |
public | function |
TFA process begin. Overrides TfaBasicSms:: |
|
TfaBasicSmsSetup:: |
public | function |
@copydoc TfaSetupPluginInterface::getSetupForm() Overrides TfaSetupPluginInterface:: |
|
TfaBasicSmsSetup:: |
public | function |
@copydoc TfaSetupPluginInterface::submitSetupForm() Overrides TfaSetupPluginInterface:: |
|
TfaBasicSmsSetup:: |
public | function |
@copydoc TfaSetupPluginInterface::validateSetupForm() Overrides TfaSetupPluginInterface:: |
|
TfaBasicSmsSetup:: |
public | function |
Plugin constructor. Overrides TfaBasicSms:: |