You are here

public static function LdapAuthenticationConfiguration::showPasswordField in Lightweight Directory Access Protocol (LDAP) 8.3

Should the password field be shown?

Parameters

\Drupal\user\UserInterface $user: User account.

Return value

bool Password status.

1 call to LdapAuthenticationConfiguration::showPasswordField()
ldap_authentication_form_user_form_alter in ldap_authentication/ldap_authentication.module
Implements hook_form_FORM_ID_alter().

File

ldap_authentication/src/Helper/LdapAuthenticationConfiguration.php, line 130

Class

LdapAuthenticationConfiguration
Configuration helper class for LDAP authentication.

Namespace

Drupal\ldap_authentication\Helper

Code

public static function showPasswordField(UserInterface $user = NULL) {
  if (!$user) {
    $user = \Drupal::currentUser();
  }

  // @TODO 2914053.
  if ($user
    ->id() == 1) {
    return TRUE;
  }

  // Hide if LDAP authenticated and updating password is not allowed,
  // otherwise show.
  if (ldap_authentication_ldap_authenticated($user)) {
    if (\Drupal::config('ldap_authentication.settings')
      ->get('passwordOption') == LdapAuthenticationConfiguration::$passwordFieldAllow) {
      return TRUE;
    }
    return FALSE;
  }
  return TRUE;
}