GPS-Mobile-Tracking-App icon indicating copy to clipboard operation
GPS-Mobile-Tracking-App copied to clipboard

connector.js i think the' if loop' is supposed to be verified== true?? (ps: line 61)...??

Open ankiclockwise opened this issue 4 years ago • 0 comments

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.
    });
  });

},``

ankiclockwise avatar Dec 24 '19 15:12 ankiclockwise