Skip to content

Instantly share code, notes, and snippets.

@CiscoKidxx
Created November 1, 2016 23:27
Show Gist options
  • Save CiscoKidxx/275e7c3d5f0d16cb155a41f4594f9b16 to your computer and use it in GitHub Desktop.
Save CiscoKidxx/275e7c3d5f0d16cb155a41f4594f9b16 to your computer and use it in GitHub Desktop.
login: function (req, res) {
var username = req.param("username");
var password = req.param("password");
Users.findOneByUsername(username).done(function(err, usr){
if(err) {
res.send(500, {error: "DB Error"});
} else {
if (usr) {
var hasher = require("password-hash");
if (hasher.verify(password, usr.password)) {
req.session.user = usr;
res.send(usr);
} else {
res.badRequest({
error: 'wrong password.'
});
}
}
else {
res.notFound();
}
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment