<commit_before>// The User model

var mongoose = require('mongoose')
var Schema = mongoose.Schema

var userSchema = new Schema({
  name: { type: String, default: '' },
  email: { type: String, default: '' },
  username: { type: String, default: '' },
  provider: { type: String, default: '' },
  password: { type: String, default: '' },
  authToken: { type: String, default: '' },
  google: {}
})

userSchema.statics = {

  /**
   * Load
   *
   * @param {Object} options
   * @param {Function} cb
   * @api private
   */

  load: function (options, cb) {
    options.select = options.select || 'name username'
    return this.findOne(options.criteria)
      .select(options.select)
      .exec(cb)
  }
}

module.exports = mongoose.model('User', userSchema)
<commit_msg>Added password hashing to user model<commit_after>// The User model

var mongoose = require('mongoose')
var Schema = mongoose.Schema

var userSchema = new Schema({
  name: { type: String, default: '' },
  email: { type: String, required: true, unique: true, lowercase: true },
  username: { type: String, default: '' },
  provider: { type: String, default: '' },
  password: { type: String, default: '' },
  authToken: { type: String, default: '' },
  google: {}
})


// Statics are on Model class
userSchema.statics = {

  /**
   * Load
   *
   * @param {Object} options
   * @param {Function} cb
   * @api private
   */

  load: function (options, cb) {
    options.select = options.select || 'name username'
    return this.findOne(options.criteria)
      .select(options.select)
      .exec(cb)
  }
}

// Method on user objects to compare password input to password saved
userSchema.methods.comparePassword = function(pw, cb) {
  bcrypt.compare(pw, this.password, function(err, isMatch) {
    if (err) {
      return cb(err)
    }
    cb(null, isMatch)
  })
}

// Hash user password before saving new user
userSchema.pre('save', function(next) {
  var user = this
  if (this.isModified('password') || this.isNew) {
    bcrypt.genSalt(10, function(err, salt) {
      if (err) {
        return next(err)
      }
      bcrypt.hash(user.password, salt, function(err, hash) {
        if (err) {
          return next(err)
        }
        user.password = <PASSWORD>
        next()
      })
    })
  } else {
    return next()
  }
})

module.exports = mongoose.model('User', userSchema)

{'fraction_non_alphanumeric': 0.15067911714770799, 'fraction_numerical': 0.0008488964346349745, 'mean_word_length': 2.9283333333333332, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2828316', 'n_tokens_mistral': 762, 'n_tokens_neox': 762, 'n_words': 203}