public function MobileNumberTfa::getForm in Mobile Number 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/TfaValidation/MobileNumberTfa.php \Drupal\mobile_number\Plugin\TfaValidation\MobileNumberTfa::getForm()
File
- src/
Plugin/ TfaValidation/ MobileNumberTfa.php, line 98 - MobileNumberTfa.php
Class
- MobileNumberTfa
- Class MobileNumberTfa is a validation and sending plugin for TFA.
Namespace
Drupal\mobile_number\Plugin\TfaValidationCode
public function getForm(array $form, FormStateInterface $form_state) {
$local_number = $this->mobileNumberUtil
->getLocalNumber($this->mobileNumber);
$numberClue = str_pad(substr($local_number, -3, 3), strlen($local_number), 'X', STR_PAD_LEFT);
$numberClue = substr_replace($numberClue, '-', 3, 0);
$form['code'] = [
'#type' => 'textfield',
'#title' => t('Verification Code'),
'#required' => TRUE,
'#description' => t('A verification code was sent to %clue. Enter the @length-character code sent to your device.', [
'@length' => $this->codeLength,
'%clue' => $numberClue,
]),
];
$form['actions']['#type'] = 'actions';
$form['actions']['login'] = [
'#type' => 'submit',
'#value' => t('Verify'),
];
$form['actions']['resend'] = [
'#type' => 'submit',
'#value' => t('Resend'),
'#submit' => [
'tfa_form_submit',
],
'#limit_validation_errors' => [],
];
return $form;
}