You are here

function password_policy_user_presave in Password Policy 7.2

Same name and namespace in other branches
  1. 8.3 password_policy.module \password_policy_user_presave()
  2. 7 password_policy.module \password_policy_user_presave()

Implements hook_user_presave().

Adds entry to password history when password is changed for a user. This should work whether the password is changed via the User module forms or programmatically via user_save().

File

./password_policy.module, line 386
Enforces password policies.

Code

function password_policy_user_presave(&$edit, $account, $category) {

  // If there is a pass value...
  if (!empty($edit['pass'])) {

    // And if this is not a newly created user...
    if (!$account->is_new) {

      // And if the pass value is not the same as before...
      if ($edit['pass'] != $account->pass) {

        // Then store the password hash to history.
        _password_policy_store_password($account->uid, $edit['pass']);
      }
    }
  }
}