Open ghost opened 4 years ago
If the problem is that it says that the user exists when it doesn't, go to your MongoDB cluster and check your users collection to make sure it's not there.
If you want to redirect to the login page you should insert res.render('login', {errors})
instead of res.render('register')
as shown in the tutorial. After you have confirmed that the email already exists in the databse. It should look something like this:
//Register user
router.post('/register', (req,res) => {
//...code
//If all the data entered is correct, proceed to check if the user with the email exists
} else {
User.findOne({email: email})
.then(user => {
if(user) {
errors.push({message: "User with that email already exists, please login"});
res.render('register', {errors});
}
//...rest of code
cannot open register page as it says "Error: Could not find the include file "("./partials/messages");"
After I register a user the page is just loading and then says that there is a user using that email already, and it doesn't redirect you to the login page.