Skip to content

Instantly share code, notes, and snippets.

@donnut
Created September 25, 2012 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donnut/3780651 to your computer and use it in GitHub Desktop.
Save donnut/3780651 to your computer and use it in GitHub Desktop.
comparePassword issue
var u = require('./user')
, mongoose = require('mongoose')
, db = mongoose.createConnection('localhost', 'mydb');
var User = u.User;
var user = new User({username: 'test4', email:'test4@test.com', password: 'secret'});
user.save(function(err) {
User.find({username: 'test4' }, function(err, user){
if ( err ) console.log(err)
user.comparePassword('hidden', function(err, isMatch) {
console.log("isMatch", isMatch);
});
});
});
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, db = mongoose.createConnection('localhost', 'mydb');
var UserSchema = new Schema({
username : String
, email : String
, password : String
});
UserSchema.methods.comparePassword = function(candidatePassword, cb) {
};
module.exports.User = db.model('User', UserSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment