function password_policy_constraint_delay_validate in Password Policy 7
Same name and namespace in other branches
- 6 constraints/constraint_delay.inc \password_policy_constraint_delay_validate()
Password validation.
File
- constraints/
constraint_delay.inc, line 31 - Constraint callback to set a minimum delay between password changes.
Code
function password_policy_constraint_delay_validate($password, $constraint, $account) {
// Bypass delay constraint, if account is marked "Force password change on
// next login".
if (isset($account->force_password_change) && $account->force_password_change) {
return TRUE;
}
$query = db_select('password_policy_history');
$query
->addExpression('MAX(created)');
$last_change = $query
->condition('uid', $account->uid)
->execute()
->fetchField();
if ($last_change) {
// Constraint is set in hours, so it gets converted to seconds with *60*60.
return _password_policy_get_request_time() - $constraint * 60 * 60 > $last_change;
}
return TRUE;
}