public function MoAuthUserManagement::submitForm in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ MoAuthUserManagement.php, line 76 - Contains support form for miniOrange 2FA Login Module.
Class
Namespace
Drupal\miniorange_2fa\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
$username = $form_values['mo_auth_username_to_reset_2fa'];
$user = user_load_by_name($username);
if ($user === FALSE) {
\Drupal::messenger()
->addError(t("User (<strong>" . $username . "</strong>) not found."));
return;
}
$query = \Drupal::database()
->delete('UserAuthenticationType');
$query
->condition('uid', $user
->id(), '=');
$query
->execute();
\Drupal::messenger()
->addStatus(t("You have reset the 2FA for <strong>%username</strong> successfully.", array(
'%username' => $username,
)));
return;
}