You are here

function _ldap_authentication_verify_user_profile in Lightweight Directory Access Protocol (LDAP) 7.2

Helper function that determines whether or not the user's profile is valid or needs to be updated on login.

Currently this only checks if mail is valid or not according to the authentication settings.

Return value

bool TRUE if the user's profile is valid, otherwise FALSE.

1 call to _ldap_authentication_verify_user_profile()
ldap_authentication_check_for_email_template in ldap_authentication/ldap_authentication.module
Form submit callback to check for an email template and redirect if needed.

File

ldap_authentication/ldap_authentication.module, line 190
This module injects itself into Drupal's Authentication stack.

Code

function _ldap_authentication_verify_user_profile() {
  global $user;
  $result = TRUE;

  // We only want non-anonymous and non-1 users.
  if ($user->uid > 1) {

    // We store the value in the session for speed.
    if (isset($_SESSION['ldap_authentication_template']) && isset($_SESSION['ldap_authentication_template']['verify_user_profile'])) {
      return $_SESSION['ldap_authentication_template']['verify_user_profile'];
    }
    if (ldap_authentication_ldap_authenticated($user)) {
      $auth_conf = ldap_authentication_get_valid_conf();
      $regex = '`' . $auth_conf->templateUsagePromptRegex . '`i';
      if (preg_match($regex, $user->mail)) {
        $result = FALSE;
      }
      $_SESSION['ldap_authentication_template'] = [
        'verify_user_profile' => $result,
      ];
    }
  }
  return $result;
}