function tfa_test_setup_form_submit in Two-factor Authentication (TFA) 7.2
Form submit handler.
File
- tests/
tfa_test.module, line 160 - A mock module for testing TFA.
Code
function tfa_test_setup_form_submit($form, &$form_state) {
$account = $form['account']['#value'];
if (empty($form_state['storage'])) {
// Unlike the standard Tfa process and tfa_form(). TfaSetup can use
// $form_state storage to persist user context.
$context = array(
'uid' => $account->uid,
);
$class = variable_get('tfa_test_setup_class', '');
$setup_plugin = new $class($context);
$tfa_setup = new TfaSetup($setup_plugin, array(), $context);
$form_state['storage']['tfa_setup'] = $tfa_setup;
$form_state['rebuild'] = TRUE;
}
elseif (!empty($form_state['storage']['tfa_setup'])) {
$tfa_setup = $form_state['storage']['tfa_setup'];
if ($tfa_setup
->submitForm($form, $form_state)) {
drupal_set_message(t('Setup complete'));
$form_state['redirect'] = 'user';
}
else {
// Setup isn't complete so rebuild.
$form_state['rebuild'] = TRUE;
}
}
}