function password_policy_past_passwords_count_constraint in Password Policy 7.2
Constraint callback for password history constraint.
1 string reference to 'password_policy_past_passwords_count_constraint'
- past_passwords.inc in plugins/
constraint/ past_passwords.inc
File
- plugins/
constraint/ past_passwords.inc, line 39
Code
function password_policy_past_passwords_count_constraint($password, $account, $constraint) {
global $user;
if (!$account) {
$account = $user;
}
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
$count = $constraint->config['past_passwords'];
$match = FALSE;
// @TODO Find out why the hook_user_load is not running correctly.
if (!isset($account->password_history)) {
password_policy_user_load(array(
$account->uid => $account,
));
}
for ($i = 0; $i < $count; $i++) {
// If we have that level of depth see if we have a match.
if (isset($account->password_history[$i])) {
$match = $match || user_check_password($password, $account->password_history[$i]);
}
else {
break;
}
}
return !$match;
}