function ldap_authentication_user_pass_validate in Lightweight Directory Access Protocol (LDAP) 8.3
Same name and namespace in other branches
- 8.4 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
- 8.2 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
- 7.2 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
- 7 ldap_authentication/ldap_authentication.module \ldap_authentication_user_pass_validate()
Change how password is validated.
Primarily a check on the password field with configurable responses as seen on the 'Authentication' tab.
Parameters
array $form: The form.
\Drupal\Core\Form\FormStateInterface $form_state: The form state.
TODO: Verify that this callback is actually needed. The form adjustments should already create a form that does not allow this.
1 string reference to 'ldap_authentication_user_pass_validate'
- ldap_authentication_form_user_pass_alter in ldap_authentication/
ldap_authentication.module - Implements hook_form_FORM_ID_alter().
File
- ldap_authentication/
ldap_authentication.module, line 95 - This module injects itself into Drupal's Authentication stack.
Code
function ldap_authentication_user_pass_validate(array &$form, FormStateInterface $form_state) {
$name_or_mail = trim($form_state
->getValue('name'));
$account = user_load_by_mail($name_or_mail);
if (!$account) {
$account = user_load_by_name($name_or_mail);
}
$config = \Drupal::config('ldap_authentication.settings');
if ($account && ldap_authentication_ldap_authenticated($account)) {
if ($config
->get('passwordOption') != LdapAuthenticationConfiguration::$passwordFieldAllow) {
if ($config
->get('ldapUserHelpLinkUrl')) {
$helpLink = \Drupal::l($config
->get('ldapUserHelpLinkText'), Url::fromUri($config
->get('ldapUserHelpLinkUrl')));
$form_state
->setErrorByName('name', t('You may not reset your password here. You must reset your password via the directions at @link.', [
'@link' => $helpLink,
]));
}
else {
$form_state
->setErrorByName('name', t("You may not reset your password here. You must reset your password via one of your organization's password management sites."));
}
}
}
}