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

[FIX 100%] Access Denied Issue & empty collections in DataBase #92

Open
getFrontend opened this issue Feb 12, 2024 · 5 comments
Open

[FIX 100%] Access Denied Issue & empty collections in DataBase #92

getFrontend opened this issue Feb 12, 2024 · 5 comments

Comments

@getFrontend
Copy link

Guys, if you are facing "Access Denied Issue" problem, now I am going to write you 100% solution to the problem 99% of the time. I came to the solution of this problem by re-reading all previous posts and trying all the tips, which in the end did not help, until I found this solution.

  1. So, the first thing to do is to make sure that the connection to the database is actually being made and the following message appears in the console "MongoDB successfully conected".

Don't listen to advice like "rename callbacks to callback". This is absolutely wrong advice! According to the documentation it should be "callbacks".

It also doesn't matter whether you have commented outdated rules or not

// useNewUrlParser: true,
// useUnifiedTopology: true,
  1. And now the most important thing! In user.js Adrian made essentially unnecessary login validation "Username invalid, it should contain 8-20 alphanumeric letters and be unique!", because we just substitute a ready-made login from Google instead of entering it manually. Because of this, the error occurred, because the login could contain characters, for example for Ukrainian - Cyrillic, or be shorter than 8 characters, or longer than 20.

Just remove this unnecessary validation, and everything will work at once! Good luck!

P.S. Suppose you want to leave the validation, and add for example Cyrillic characters, then you will need this template:

/^(?=.{3,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._\u0400-\u04FF]+(?<![_.])$/

@getFrontend getFrontend changed the title [FIX 100%] Access Denied Issue [FIX 100%] Access Denied Issue & empty collections in DataBase Feb 12, 2024
@Pheeleex
Copy link

It still didn't work for me

@getFrontend
Copy link
Author

It still didn't work for me

Check first if you have a connection to the database and if a message appears in the console?

@Onunkwor
Copy link

@Pheeleex what worked for me was logging the information I received from google
Screenshot 2024-02-19 211654
adrian used profile.name for the user name but the data received from the profile had no name for me it was given_name so I used that instead and it worked for me also make sure the schema matched the User.create e.g in the schema I used userName but I used username in the username in the User.create
Screenshot 2024-02-19 211718

@Pheeleex
Copy link

@getFrontend yeah, it shows mongoDb is connected on my terminal and the user appears in my mongoDB collection, i just keep getting a not permitted to sign in error each time i try.

@Pheeleex
Copy link

@Onunkwor okay, I'll try that.

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

3 participants