<commit_before>'use strict'
var mongoose = require('mongoose');
var crypto = require('crypto')

var schema = new mongoose.Schema ({
	firstName: String,
	lastName: String,
	email: {type: String, unique: true, required: true},
	password: String,
	salt: String,
  dateJoined: {type: Date, default: Date.now},
<<<<<<< HEAD
	files: [{type: mongoose.Schema.Types.ObjectId, ref:'File'}]
=======
  filePreferences: [String],
	files: [{type: mongoose.Schema.Types.ObjectId, ref:'file'}]
>>>>>>> master
})

var generateSalt = function() {
   return crypto.randomBytes(16).toString('base64');
};

var encryptPassword = function(plainText, salt) {
   var hash = crypto.createHash('sha1');
   hash.update(plainText);
   hash.update(salt);
   return hash.digest('hex');
};

schema.pre('save', function(next) {

   if (this.isModified('password')) {
       this.salt = this.constructor.generateSalt();
       this.password = this.constructor.encryptPassword(this.password, this.salt);
   }

   next();

});

schema.statics.generateSalt = generateSalt;
schema.statics.encryptPassword = encryptPassword;

schema.method('correctPassword', function(candidatePassword) {<commit_msg>resolved merge conflicts in user schema<commit_after>'use strict'
var mongoose = require('mongoose');
var crypto = require('crypto')

var schema = new mongoose.Schema ({
	firstName: String,
	lastName: String,
	email: {type: String, unique: true, required: true},
	password: String,
	salt: String,
  dateJoined: {type: Date, default: Date.now},
	files: [{type: mongoose.Schema.Types.ObjectId, ref:'File'}],
  filePreferences: [String],
})

var generateSalt = function() {
   return crypto.randomBytes(16).toString('base64');
};

var encryptPassword = function(plainText, salt) {
   var hash = crypto.createHash('sha1');
   hash.update(plainText);
   hash.update(salt);
   return hash.digest('hex');
};

schema.pre('save', function(next) {

   if (this.isModified('password')) {
       this.salt = this.constructor.generateSalt();
       this.password = this.constructor.encryptPassword(this.password, this.salt);
   }

   next();

});

schema.statics.generateSalt = generateSalt;
schema.statics.encryptPassword = encryptPassword;

schema.method('correctPassword', function(candidatePassword) {
{'fraction_non_alphanumeric': 0.1601597160603372, 'fraction_numerical': 0.0044365572315882874, 'mean_word_length': 5.178082191780822, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '302468', 'n_tokens_mistral': 722, 'n_tokens_neox': 698, 'n_words': 151}