Skip to content

Instantly share code, notes, and snippets.

@ric03uec
Created March 30, 2012 15:09
Show Gist options
  • Save ric03uec/2252174 to your computer and use it in GitHub Desktop.
Save ric03uec/2252174 to your computer and use it in GitHub Desktop.
login route handler
app.post('/login', function(req, res){
logger.log('Serving request for url [POST] ' + req.route.path);
var username = req.body.User;
var password = req.body.Password;
/**
* The following can be replaced by any other form
* of authentication
*/
User.validateUser(username, password, function(err, user){
if(err && !user){
res.json({
retStatus : 'failure'
});
}else{
req.session.user = user;
res.json({
retStatus : 'success',
user : user
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment