Back

duplicate document in collection, nextjs 14

  • 0
  • Auth
  • Web
ingcarlos
11 Mar, 2024, 02:26

Hello guys, I hope you can help me. When I register a user with google auth and then save that user in a collection called users; a document is created twice.

what is the flow like: I have a Google button, when clicked it registers the user in auth appwrite normally. After that, in this case, it redirects me to the dashboard and there I execute a use effect to obtain the session, validate that the user exists and after that I use .createDocument to save that user in a collection.

The funny thing is that it only happens when a user registers with their Google account, if they register with normal without providers, it only creates a single document

I appreciate your suggestions

TL;DR
Issue: Duplicate document created in collection when registering a user with Google auth using Next.js 14. Solution: The issue occurs when registering a user with Google auth, leading to two documents created in the collection instead of one. 1. Possible cause: The registration process with Google auth might be triggering the creation of two documents unintentionally. 2. Suggestion: Check the implementation flow and the use of `.createDocument` when registering a user with Google auth. Ensure that the process is correctly handling the registration and document creation. 3. Recommendation: Debug the code related to registering users with Google auth to identify and fix the issue causing duplicate document
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more