function tfa_code_form in Two-factor Authentication (TFA) 6
Same name and namespace in other branches
- 7 tfa.pages.inc \tfa_code_form()
Form for code entry.
1 string reference to 'tfa_code_form'
- tfa_menu in ./
tfa.module - Implements hook_menu().
File
- ./
tfa.pages.inc, line 10 - tfa.pages.inc
Code
function tfa_code_form($form_state, $uid, $hash = NULL) {
// Check flood.
if (!flood_is_allowed('tfa_validate', variable_get('tfa_hourly_threshold', 5))) {
drupal_set_message(t('You have reached the threshold for incorrect code entry attempts. Please try again later.'), 'error');
drupal_access_denied();
exit;
}
$account = user_load(array(
'uid' => $uid,
));
$form['desc'] = array(
'#value' => t('<div class="messages ok">A message containing the code has been sent. Enter your received login code to continue.</div>'),
);
$form['uid'] = array(
'#type' => 'value',
'#value' => $uid,
);
$form['code'] = array(
'#type' => 'textfield',
'#title' => t('Code'),
);
// Provide option to resend code.
$form['resend'] = array(
'#type' => 'fieldset',
'#title' => t('Resend code'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('If you have not received the code you can resend it. You can only resend the code !count times per hour.', array(
'!count' => variable_get('tfa_hourly_threshold', 5),
)),
);
$form['resend']['send'] = array(
'#type' => 'button',
'#value' => t('Resend code'),
);
$form['login'] = array(
'#type' => 'submit',
'#value' => t('Log in'),
);
return $form;
}