Created
November 16, 2021 01:04
-
-
Save hieptl/d893bf25f3f734cca5c345706ded36bc to your computer and use it in GitHub Desktop.
auth.js - routes - server - Instagram Clone React Node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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