Skip to content

Instantly share code, notes, and snippets.

Created January 5, 2017 16:35
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 anonymous/7b125a5b3e79e86e81192ef59f164201 to your computer and use it in GitHub Desktop.
Save anonymous/7b125a5b3e79e86e81192ef59f164201 to your computer and use it in GitHub Desktop.
router.post('/login', async (ctx, next) => {
let username = ctx.request.body.username;
let password = ctx.request.body.password;
console.log(ctx.request.body.username);
try{
let infoUser = await db.query("SELECT password from utilizador WHERE username = '"+ username+"'",true);
if(infoUser.length > 0) {
//TODO check password
console.log(infoUser);
ctx.body = getToken(username, password);
}
else{
ctx.response.status = 200;
ctx.body = {
result: "NOT"
}// MIsssing errors
}
}
catch(err){
console.log(err);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment