Created
April 3, 2012 22:15
-
-
Save note/2295859 to your computer and use it in GitHub Desktop.
various
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
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