Guest User

Untitled

a guest
Apr 3rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. var mongoose = require('mongoose');
  2. var bcrypt = require('bcrypt');
  3. var userSchema = mongoose.Schema({
  4. local: {
  5. username: String,
  6. password: String
  7. },
  8. facebook: {
  9. id: String,
  10. token: String,
  11. email: String,
  12. name: String
  13. },
  14. google: {
  15. id: String,
  16. token: String,
  17. email: String,
  18. name: String
  19. }
  20. });
  21.  
  22. userSchema.methods.generateHash = function(password){
  23. return bcrypt.hashSync(password, bcrypt.genSaltSync(9));
  24. }
  25.  
  26. userSchema.methods.validPassword = function(password){
  27. return bcrypt.compareSync(password, this.local.password);
  28. }
  29.  
  30. module.exports = mongoose.model('User', userSchema);
Add Comment
Please, Sign In to add comment