You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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 userrouter.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
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.
The text was updated successfully, but these errors were encountered: