You are here

function password_policy_constraint_username_validate in Password Policy 7

Same name and namespace in other branches
  1. 6 constraints/constraint_username.inc \password_policy_constraint_username_validate()

Password validation.

1 call to password_policy_constraint_username_validate()
PasswordPolicyTestCase::testUsernameConstraint in tests/password_policy.test
Test username constraint.

File

constraints/constraint_username.inc, line 29
Password policy constraint callbacks.

Code

function password_policy_constraint_username_validate($password, $constraint, $account) {

  // The username may be empty if not entered on the user registration form.
  if (!$account->name) {
    return TRUE;
  }
  $username_lowercase = drupal_strtolower($account->name);
  $password_lowercase = drupal_strtolower($password);
  return strpos($password_lowercase, $username_lowercase) === FALSE;
}