Skip to content

Instantly share code, notes, and snippets.

@WoolDoughnut310
Created October 28, 2022 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WoolDoughnut310/9405c6f5bfa1d81502f0230f8555a1ef to your computer and use it in GitHub Desktop.
Save WoolDoughnut310/9405c6f5bfa1d81502f0230f8555a1ef to your computer and use it in GitHub Desktop.
router.post("/login", async (req, res) => {
const db = getDb();
const users = db.collection<User>("user");
const user = await users.findOne({
email: req.body.email,
});
const passwordValid = await bcrypt.compare(
req.body.password,
user.password
);
if (user === null || !passwordValid) {
return res.status(401).json({
accessToken: null,
message: "Email or password is incorrect",
});
}
...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment