daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Sep 24th, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var mongoose = require('mongoose');
  2. var bcrypt = require('bcrypt-nodejs');
  3.  
  4. var user = mongoose.Schema({
  5.     local: {
  6.         firstname: String,
  7.         lastname: String,
  8.         email: String,
  9.         password: String
  10.     },
  11. });
  12.  
  13. user.methods.generateHash = function(password) {
  14.     return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null);
  15. };
  16. user.methods.validPassword = function(password) {
  17.     return bcrypt.compareSync(password, this.local.password);
  18. };
  19.  
  20. module.exports = mongoose.model('User' , user);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top