Skip to content

Instantly share code, notes, and snippets.

@note
Created April 3, 2012 22:15
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 note/2295859 to your computer and use it in GitHub Desktop.
Save note/2295859 to your computer and use it in GitHub Desktop.
various
exports.processLogin = function (req, res){
var User = mongoose.model('Users');
var id;
var u = User.where('login', req.body.login).find({}, function(err, docs){
req.session.userId = docs[0]._id;
User.where('login', req.body.login).where('password', models.createHash(req.body.password)).count(function(err, count){
if(err || count == 0)
res.render('login', {title: 'log in'});
else{
req.session.loggedIn = true;
console.log(id);
res.redirect('/add');
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment