Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require("mongoose");
- mongoose.connect("mongodb://localhost/store2");
- var bcrypt = require("bcrypt-nodejs");
- var Schema = mongoose.Schema;
- var userSchema = new Schema({
- username: {type: String, required: true},
- email: {type: String, required: true},
- password: {type: String, required: true},
- confirmpassword: {type: String, required: true},
- passwordResetToken: {type: String, default: ""},
- passwordResetExpires: {type: Date, default: Date.now},
- profileimage: {type:String}
- });
- userSchema.methods.encryptPassword = function (password) {
- return bcrypt.hashSync(password, bcrypt.genSaltSync(10), null);
- };
- userSchema.methods.validPassword = function (password) {
- 'use strict';
- return bcrypt.compareSync(password, this.password);
- };
- userSchema.methods.encryptPassword = function (confirmpassword) {
- "use strict";
- return bcrypt.hashSync(confirmpassword, bcrypt.genSaltSync(10), null);
- };
- userSchema.methods.validPassword = function (confirmpassword) {
- return bcrypt.compareSync(confirmpassword, this.confirmpassword);
- };
- module.exports = mongoose.model("Buyer", userSchema);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement