Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose'),
- bcrypt = require('bcrypt-nodejs');
- var userSchema = new mongoose.Schema({
- username: { type: String, required: true, unique: true },
- password: { type: String, required: true },
- email: String,
- created_at: Date,
- updated_at: Date,
- admin: Boolean
- });
- 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement