adrianhajdin / project_next_14_ai_prompt_sharing

Next.js recently became the official React framework as outlined in React docs. In this course, you'll learn the most important Next.js concepts and how they fit into the React ecosystem. Finally, you'll put your skills to the test by building a modern full-stack Next 14 application.
https://www.jsmastery.pro/ultimate-next-course
2.9k stars 426 forks source link

Access Denied Error #9

Open Shaharyar07 opened 1 year ago

Shaharyar07 commented 1 year ago

Access Denied You do not have permission to sign in.

image image

chameerapre commented 1 year ago

Database-Access-Cloud-MongoDB-Cloud

Try giving MongoDB roles as readWriteAnyDatabase

Shaharyar07 commented 1 year ago

Database-Access-Cloud-MongoDB-Cloud

Try giving MongoDB roles as readWriteAnyDatabase

Done that already not working

davidcastagnetoa commented 1 year ago

@Shaharyar07 I was the same error, first, try to remove the match line in user.js model, in my case I use this match and works:

match: [/^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/, "Username invalid, it should contain 8-20 alphanumeric letters and be unique!"]

Something like this:

username: {
    type: String,
    required: [true, 'Username is required!'],
    match: [/^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/, "Username invalid, it should contain 8-20 alphanumeric letters and be unique!"]
  },

or the error is maybe in your google console, in your auth credentials, you have to use in Authorized redirect URIs: http://localhost:3000 and http://localhost:3000/api/auth/callback/google , review your .env file and your GOOGLE_ID and GOOGLE_SECRET. I hope this lines help you

vitegod commented 1 year ago

I tried to delete match line in user.js, then it works. Hope this help to you

ChayneW commented 1 year ago

piggybacking off of @vite551314, deleted match line and it worked, but figured we need that line, so found on Mongoose and MongoDB docs that they use '$match' (see links below), can't confirm that "$" is the difference maker, but what's been helping me get the google account that was previously denied to connect:

https://www.mongodb.com/docs/manual/reference/operator/aggregation/match/ https://stackoverflow.com/questions/37722795/multiple-and-with-multiple-or-in-match-mongoose https://mongoosejs.com/docs/api/aggregate.html#Aggregate()