Created
September 25, 2012 08:33
-
-
Save donnut/3780651 to your computer and use it in GitHub Desktop.
comparePassword issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var u = require('./user') | |
, mongoose = require('mongoose') | |
, db = mongoose.createConnection('localhost', 'mydb'); | |
var User = u.User; | |
var user = new User({username: 'test4', email:'[email protected]', 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); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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