Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register #71

Open
ghost opened this issue May 21, 2020 · 2 comments
Open

Register #71

ghost opened this issue May 21, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented May 21, 2020

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.

@XBShu
Copy link

XBShu commented Nov 11, 2020

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

@hcsec20
Copy link

hcsec20 commented Feb 8, 2021

cannot open register page as it says "Error: Could not find the include file "("./partials/messages");"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants