Open aqilmarwan opened 1 year ago
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!"] },
remove this match: and try again
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!"] },
remove this match: and try again
Commented/deleted the match lines out and tried using match: [/^(?=.{8,20}$)(?![_.])(?!.*[_.]{2})[a-zA-Z0-9._]+(?<![_.])$/, "Username invalid, it should contain 8-20 alphanumeric letters and be unique!"]
,
still didn't get through the authentication.
do you have a repo up so we can see what you did wrong?
do you have a repo up so we can see what you did wrong?
I didn't change anything except for (env & match lines) to make it runs on my local machine. https://github.com/aqilmarwan/promptopia
I was having this issue before too. This is after you signed in with google? How did you get to this access denied? Do you have your google URL and callbacks to localhost?
I was having this issue before too. This is after you signed in with google? How did you get to this access denied? Do you have your google URL and callbacks to localhost?
yes i have that called in google auth
if (!userExists) { await User.create({ email: profile.email, username: profile.name.replaceAll(" ", "").toLowerCase(), image: profile.picture, }); }
added .replaceAll(" ", "").toLowerCase(),
I checked what you recommended, MongoDb looks to be connected. But I get always have the access denied, I got this in the terminal when I click on signIn:
`- wait compiling /api/auth/[...nextauth]/route (client and server)...
I checked what you recommended, MongoDb looks to be connected. But I get always have the access denied, I got this in the terminal when I click on signIn:
`- wait compiling /api/auth/[...nextauth]/route (client and server)...
- event compiled client and server successfully in 774 ms (776 modules) MongoDB connected Error checking if user exists: _models_user__WEBPACK_IMPORTED_MODULE_2__.default.findOne is not a function`
I finally find it and get an error in models >user.js, stupid error. I write : "const User = models.User || ("User", UserSchema)" instead of "const User = models.User || model("User", UserSchema)".
@aqilmarwan I encountered an 'Access Denied' error with the following message: 'Username invalid, it should contain 8-20 alphanumeric letters and be unique!' I tried using another Google account, and it worked correctly. Then, I realized that the denied Google account had my full name as the username, which exceeded the character limit allowed by the MongoDB model. I changed my name in the Google account to confirm, and it worked. However, this is not a production-ready solution. To address this issue, one can modify the model to allow a broader range of username types by customizing the UserSchema in the 'const User' object. Best regards.
@aqilmarwan I encountered an 'Access Denied' error with the following message: 'Username invalid, it should contain 8-20 alphanumeric letters and be unique!' I tried using another Google account, and it worked correctly. Then, I realized that the denied Google account had my full name as the username, which exceeded the character limit allowed by the MongoDB model. I changed my name in the Google account to confirm, and it worked. However, this is not a production-ready solution. To address this issue, one can modify the model to allow a broader range of username types by customizing the UserSchema in the 'const User' object. Best regards.
You can uoda6e the regex for the username
change MONGODB_URI back to older version and comment to disable "match" line in user.js model and code will run. Goodluck
Tried every possible ways but still didn't get through.