function aes_user_alter in AES encryption 7
Implements hook_user_alter().
2 calls to aes_user_alter()
- aes_user_insert in ./
aes.module - Implements hook_user_insert().
- aes_user_update in ./
aes.module - Implements hook_user_update().
File
- ./
aes.module, line 217 - Main file of the AES encryption module.
Code
function aes_user_alter(&$edit, $account) {
// Return immediately if the password is not in $_POST.
if (!isset($_POST['pass']) || !isset($_POST['pass']['pass1'])) {
return;
}
// Get the password from $_POST here since it's already hashed in $edit.
$plain_text_password = $_POST['pass']['pass1'];
if (!empty($plain_text_password) && $account->uid) {
$password = aes_encrypt($plain_text_password);
if (strlen($password) > AES_PASSWORD_MAX_LENGTH) {
drupal_set_message(t("Couldn't update AES password since it's too long."), "error");
}
else {
// If this user doesn't have a password and creation of encrypted
// passwords is enabled, insert one now.
if (aes_password_exists($account->uid) == FALSE) {
if (variable_get("aes_convert", FALSE)) {
db_insert('aes_passwords')
->fields(array(
'uid' => $account->uid,
'pass' => $password,
))
->execute();
}
}
else {
db_update('aes_passwords')
->fields(array(
'pass' => $password,
))
->where("uid = :uid", array(
':uid' => $account->uid,
))
->execute();
}
}
}
}