Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created September 28, 2021 04:54
Show Gist options
  • Save hieptl/5e27d699084cf3c4373226102c76a4e4 to your computer and use it in GitHub Desktop.
Save hieptl/5e27d699084cf3c4373226102c76a4e4 to your computer and use it in GitHub Desktop.
auth.js - API - Tinder Clone
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 (err, result) {
if (result && result.length !== 0) {
res.status(200).jsonp({ gender: result[0].user_gender, uid: result[0].user_cometchat_uid });
} 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