You are here

function aes_aes_config_change in AES encryption 7

Implements hook_aes_config_change().

File

./aes.admin.inc, line 329
AES encryption module administration settings.

Code

function aes_aes_config_change($decrypt_params, $encrypt_params) {

  // Re encrypt user paswords.
  $accounts = db_select('aes_passwords', 'p')
    ->fields('p', array(
    'uid',
    'pass',
  ))
    ->condition('uid', 0, '!=')
    ->execute()
    ->fetchAll();
  foreach ($accounts as $account) {
    $decrypt_params['string'] = $account->pass;
    $plain_pass = call_user_func_array('aes_decrypt', $decrypt_params);
    $encrypt_params['string'] = $plain_pass;
    $new_pass = call_user_func_array('aes_encrypt', $encrypt_params);
    db_update('aes_passwords')
      ->fields(array(
      'pass' => $new_pass,
    ))
      ->where("uid = :uid", array(
      ':uid' => $account->uid,
    ))
      ->execute();
  }
  if (count($accounts)) {
    drupal_set_message(t("Updated the passwords of @updates_num users because of a change in encryption settings.", array(
      '@updates_num' => count($accounts),
    )));
  }
}