function tfa_basic_disable_form_submit in TFA Basic plugins 7
Disable form submit.
1 string reference to 'tfa_basic_disable_form_submit'
File
- ./
tfa_basic.pages.inc, line 298
Code
function tfa_basic_disable_form_submit($form, &$form_state) {
$account = $form_state['storage']['account'];
if ($form_state['values']['op'] === $form_state['values']['cancel']) {
drupal_set_message(t('TFA disable canceled.'));
$form_state['redirect'] = 'user/' . $account->uid . '/security/tfa';
return;
}
$params = array(
'account' => $account,
);
tfa_basic_setup_save_data($account, array(
'status' => FALSE,
));
// Delete TOTP code.
$totp = new TfaTotp(array(
'uid' => $account->uid,
));
$totp
->deleteSeed();
// Delete recovery codes.
$recovery = new TfaBasicRecoveryCodeSetup(array(
'uid' => $account->uid,
));
$recovery
->deleteCodes();
// Delete trusted browsers.
$trusted = new TfaTrustedBrowserSetup(array(
'uid' => $account->uid,
));
$trusted
->deleteTrustedBrowsers();
watchdog('tfa_basic', 'TFA disabled for user @name UID !uid', array(
'@name' => $account->name,
'!uid' => $account->uid,
), WATCHDOG_NOTICE);
// E-mail account to inform user that it has been disabled.
drupal_mail('tfa_basic', 'tfa_basic_disabled_configuration', $account->mail, user_preferred_language($account), $params);
drupal_set_message(t('TFA has been disabled.'));
$form_state['redirect'] = 'user/' . $account->uid . '/security/tfa';
}