Created
September 28, 2021 04:54
-
-
Save hieptl/5e27d699084cf3c4373226102c76a4e4 to your computer and use it in GitHub Desktop.
auth.js - API - Tinder Clone
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 (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