For login using mysql and nodejs for angular2 application' postman loading only not responding anything and console response POST /login - - ms - -
var express = require('express');
var router = express.Router();
var login = require('../models/login');
router.post('/:username?', function (req, res, next) {
var username=req.body.username;
var password=req.body.password;
if (req.params.username) {
login.getAuth(req.params.username, function (err,results, rows) {
if (err) {
// console.log("error ocurred",error);
res.send({
"code":400,
"failed":"error ocurred"
})
}else{
// console.log('The solution is: ', results);
if(results.length >0){
if([0].password == password){
res.send({
"code":200,
"success":"login sucessfull"
});
}
else{
res.send({
"code":204,
"success":"Username and password does not match"
});
}
}
else{
res.send({
"code":204,
"success":"Username does not exits"
});
}
}
});
}
});
module.exports = router;
Am trying to get username and password from user and compare with mysql db and authenticate and send response back
via Raghavendra Ajegaonkar
No comments:
Post a Comment