# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: C:\Projects\NRAM\sites\all\modules\salt
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: salt.module
--- salt.module Base (BASE)
+++ salt.module Locally Modified (Based On LOCAL)
@@ -32,7 +32,7 @@
  * Implementation of hook_form_alter.
  */
 function salt_form_alter(&$form, $form_state, $form_id) {
-  if (in_array($form_id, array('user_login_block', 'user_login', 'user_profile_form', 'user_register'))) {
+  if (in_array($form_id, array('user_login_block', 'user_login'))) {
     // Give salt module's validate function preference over user_login.
     array_unshift($form['#validate'], 'salt_login_validate');
   }
@@ -46,13 +46,26 @@
 
   if (strlen($form_state['values']['pass'])) {
     $salted_pass = $form_state['values']['pass'] . variable_get('salt', '');
+    form_set_value($form['pass'], $salted_pass, $form_state);
+  }
+}
 
-    // The user_profile_form is structured differently to the login forms.
-    if($form_state['values']['form_id'] == 'user_profile_form') {
-      form_set_value($form['account']['pass'], $salted_pass, $form_state);
+/**
+ * Updates the 'pass' column when inserting or updating a user account.
+ * This avoids appending the salt string to the plaintext password on the account.
+ */
+function salt_user($op, &$edit, &$account, $category = NULL) {
+  switch($op) {
+    case 'insert':
+    case 'update':
+      $pass = trim($edit['pass']);
+      if(strlen($pass) && !empty($account->uid)) {
+        $salted_password = md5($pass . variable_get('salt', ''));
+        $result = db_query("UPDATE {users} SET pass = '%s' WHERE uid = %d", $salted_password, $account->uid);
+        if(($changed = db_affected_rows()) != 1) {
+          watchdog('security', "Updated !changed rows when changing password for user #!uid: @name", array('!changed' => $changed, '!uid' => $account->uid, '@name' => $account->name));
     }
-    else {
-      form_set_value($form['pass'], $salted_pass, $form_state);
+        unset($edit['pass']);
\ No newline at end of file
     }
   }
 }
