Skip to content

Instantly share code, notes, and snippets.

@shinecita
Created November 22, 2012 16:05
Show Gist options
  • Save shinecita/4131876 to your computer and use it in GitHub Desktop.
Save shinecita/4131876 to your computer and use it in GitHub Desktop.
router.post('/signin', function (req, res) {
User
.findOne({ email: req.body.email }, function(err, user) {
if(user && user.__password.salt) {
pass.hash(req.body.password, user.__password.salt, function(err, hash) {
if(user.__password.hash == hash) {
req.session._userId = user._id;
res.json(user);
} else {
res.send(401);
}
});
if(err) {
//do something
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment