Advertisement
Guest User

Untitled

a guest
Jun 27th, 2014
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. var mongoose = require('mongoose');
  2. var bcrypt = require('bcrypt-nodejs');
  3.  
  4. var buyerSchema = new mongoose.Schema({
  5. local: {
  6. name: { type: String },
  7. email : { type: String, require: true, unique: true },
  8. password: { type: String, require:true },
  9. dob:{type:Date},
  10. mobile_number:{type:String},
  11. shipping_address:{type:Object},
  12. billing_address:{type:Object},
  13. isLoggedIn : Number
  14. },
  15. facebook: {
  16. id : { type: String },
  17. token : { type: String },
  18. email : { type: String },
  19. name : { type: String }
  20. },
  21. twitter: {
  22. id : { type: String },
  23. token : { type: String },
  24. displayName : { type: String },
  25. username : { type: String }
  26. }
  27. });
  28.  
  29. // Generate a hash
  30. buyerSchema.methods.generateHash = function(password) {
  31. return bcrypt.hashSync(password, brcypt.genSaltSync(8), null);
  32. };
  33.  
  34. // Check if password is valid
  35. buyerSchema.methods.validPassword = function(password) {
  36. return bcrypt.compareSync(password, this.local.password);
  37. };
  38.  
  39. var Buyer = mongoose.model('Buyer',buyerSchema);
  40.  
  41. module.exports = Buyer;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement