Skip to content

Instantly share code, notes, and snippets.

@shinecita
Created September 11, 2012 19:42
Show Gist options
  • Save shinecita/3701470 to your computer and use it in GitHub Desktop.
Save shinecita/3701470 to your computer and use it in GitHub Desktop.
populate self referenced
app.post('/login', function(req, res) {
User
.where('email', req.body.email)
.populate('organizations')
.findOne(function(err, user) {
if(user) {
console.log(user);
user.authenticate(req.body.password, function(err) {
if(!err) {
req.session._userId = user.get('id');
res.redirect('/');
} else {
res.redirect('back');
}
});
} else {
res.redirect('back');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment