You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
541 B

var mongoose = require('mongoose');
var locationSchema = require('./locations').schema;
var bcrypt = require('bcrypt-nodejs');
var userSchema = mongoose.Schema({
username: String,
email: String,
password: String,
locations: [locationSchema]
});
userSchema.methods.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
}
userSchema.methods.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
}
module.exports = mongoose.model('User', userSchema);