title: hash password on create and update
body: <p>I am trying to hash a password for users when the record is created and when the user updates their password. On creation, I can do something like</p>
  
  <pre><code>User.beforeCreate((user, options) =&gt; {
    user.password = encryptPassword(user.password)
  })
  </code></pre>
  
  <p>Which will be easily executed and hash the password for new users. But I have an issue when updating the password. If I just do</p>
  
  <pre><code>User.beforeUpdate((user, options) =&gt; {
    user.password = encryptPassword(user.password)
  })
  </code></pre>
  
  <p>then everytime users updating their record (i.e update name, address, etc) it triggers the hook and re-hash the password.</p>
  
  <p>How can I tell when the password is changed so that I can trigger the hook? Also instead of having those 2 hooks, how can I just use <code>beforeSave</code> to achieve the same result?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As per requested my User definition is as simple as</p>
  
  <pre><code>sequelize.define(
    'user',
    {
      id: {
        type:          Sequelize.INTEGER,
        autoIncrement: true,
        primaryKey:    true,
      },
      emailAddress: {
        field:        'email_address',
        type:         Sequelize.STRING,
        allowNull:    false,
        unique:       true,
        validate: {
          isEmail: {
            args:     true,
            msg:      "Email is not valid"
          }
        },
      },
      password: {
        type:         Sequelize.STRING,
        allowNull:    false,
        validate: {
          min: {
            args:     6,
            msg:      "Password must be more than 6 characters"
          }
        }
      }
    }
  )
  </code></pre>