Hi,
I am working with Mongoose, and I run the following query after posting a verify token and email. The idea is that the user will use a secretToken emailed to them, alongside their email, to turn their account active. However, I am having trouble finding the Mongoose record based on the findOne function:
router.post("/verify", function(req, res, next){
const { secretToken } = req.body;
const { email } = req.body;
//find account that matches the secret token
const user = User.findOne({ "email": email, "secretToken" : secretToken });
// this does not seem to get the right records!
console.log(user);
//If we fail to match token and email, i.e. user is NULL
if(!user) {
req.flash("error", "Verification has failed, please try again");
res.redirect("verify");
}
});
Any guidance is much appreciated!