Created
October 28, 2022 14:59
-
-
Save WoolDoughnut310/9405c6f5bfa1d81502f0230f8555a1ef to your computer and use it in GitHub Desktop.
This file contains 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
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