Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created November 16, 2021 01:04
Show Gist options
  • Save hieptl/d893bf25f3f734cca5c345706ded36bc to your computer and use it in GitHub Desktop.
Save hieptl/d893bf25f3f734cca5c345706ded36bc to your computer and use it in GitHub Desktop.
auth.js - routes - server - Instagram Clone React Node
module.exports = function ({ app, dbConn }) {
app.post("/login", (req, res) => {
const { email, password } = req.body;
if (email && password) {
const sql = "SELECT * FROM user_account WHERE user_email = ? AND user_password = ?";
dbConn.query(sql, [email, password], function (error, response) {
if (response && response.length !== 0) {
res.status(200).jsonp({ ...response[0] });
} else {
res.status(200).jsonp({ message: "Your username or password is not correct" });
}
});
} else {
res.status(200).jsonp({ message: "Your username or password is not correct" });
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment