Open Shaharyar07 opened 1 year ago
Try giving MongoDB roles as readWriteAnyDatabase
Try giving MongoDB roles as readWriteAnyDatabase
Done that already not working
@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
I tried to delete match line in user.js, then it works. Hope this help to you
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()
Access Denied You do not have permission to sign in.