public function MoAuthLoginSettings::validateForm in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Form validation 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 FormBase::validateForm
File
- src/
Form/ MoAuthLoginSettings.php, line 621 - Contains support form for miniOrange 2FA Login Module.
Class
- MoAuthLoginSettings
- Showing LoginSetting form info.
Namespace
Drupal\miniorange_2fa\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
if ($form_values['mo_auth_two_factor_invoke_2fa_depending_upon_IP'] === 1 && !empty($form_values['mo_auth_two_factor_whitelist_IP'])) {
$mo_whitelist_IPs = preg_replace('/\\s+/', '', $form_values['mo_auth_two_factor_whitelist_IP']);
$valid_IPs = MoAuthUtilities::check_for_valid_IPs($mo_whitelist_IPs);
if ($valid_IPs !== TRUE) {
$form_state
->setErrorByName('mo_auth_two_factor_whitelist_IP', $this
->t($valid_IPs));
}
}
if ($form_values['mo_auth_two_factor_override_login_labels'] === 1) {
if (empty($form_values['mo_auth_two_factor_username_title'])) {
$form_state
->setErrorByName('mo_auth_two_factor_username_title', $this
->t('Username title is mandatory to enable<strong> Override login form username title and description</strong> option'));
}
if (empty($form_values['mo_auth_two_factor_username_description'])) {
$form_state
->setErrorByName('mo_auth_two_factor_username_description', $this
->t('Username description is mandatory to enable<strong> Override login form username title and description</strong> option'));
}
}
if ($form_values['only_some_admins_can_edit_2fa_configs'] === 1 && empty($form_values['list_of_admins_who_can_edit_2fa_configs'])) {
$form_state
->setErrorByName('list_of_admins_who_can_edit_2fa_configs', $this
->t('List of user-id of admins is mandatory to<strong>allow only some admins to edit 2FA opt-in and opt-out configurations</strong>'));
}
}