GPS-Mobile-Tracking-App
GPS-Mobile-Tracking-App copied to clipboard
connector.js i think the' if loop' is supposed to be verified== true?? (ps: line 61)...??
loginUser: function (req, res) { pool.getConnection(function (err, connection) { if (err) throw err; // not connected!
var sql = 'SELECT * FROM `user` WHERE `email` = ?';
var values = [req.body.inputEmail]
// Use the connection
connection.query(sql, values, function (error, results, fields) {
if (error) {
resultsNotFound["errorMessage"] = "Something went wrong with Server.";
return res.send(resultsNotFound);
}
if (results =="") {
resultsNotFound["errorMessage"] = "User Id not found.";
return res.send(resultsNotFound);
}
password(req.body.inputPassword).verifyAgainst(results[0].password, function (error, verified) {
//bcrypt.compare(req.body.inputPassword, results[0].password, function (err, result) {
if (verified == true) {
var token = {
"token": jwt.sign(
{ email: req.body.inputEmail },
process.env.JWT_SECRET,
{ expiresIn: '30d' }
)
}
resultsFound["data"] = token;
res.send(resultsFound);
} else {
resultsNotFound["errorMessage"] = "Incorrect Password.";
return res.send(resultsNotFound);
}
});
// When done with the connection, release it.
connection.release(); // Handle error after the release.
if (error) throw error; // Don't use the connection here, it has been returned to the pool.
});
});
},``