Duplicate user when signup with Facebook
In my application, I have a button: Signup with Facebook. If user double click this button, two requests will be sent to parse-server, and if it is fast enough, two users with same information will be created. This doesn't happen on Parse.com
I've managed to reproduce this and am working on a fix.
That said, you should still adjust your UI to prevent a second request, as one of the two requests will fail after this change, which might have unexpected effects on your UI.
OK, while writing a test case, I've found that we need to have a unique index on the facebook auth data, which we currently have no good way to add, meaning this will be a long term fix. I'd suggest adding the unique index yourself in the meantime.
I just face same problem. I have login/signup with Facebook. All works fine. I went and changed my Facebook password. I have already program to check in such scenario logout, which my app did and unlinked user from Facebook. As expected I was prompted to sign in with new password, which I did to sign in. When signed in parseFacebookUtils returned a duplicate user instead of linking me to existing user object. Well I can very well have a work around to handle this. However it is not clean solution.
We're occasionally seeing multiple anonymous users created for the same auth data. We try hard to prevent concurrent requests from the client so I'm not sure how this is happening. We create the users with a REST call from cloud code. Thinking this could be related.
Just want to spell out the solution as I missed it on the first read, the indexes created from scratch would be:
db.getCollection("_User").createIndex( { "_auth_data_anonymous.id": 1 }, { unique: true, sparse: true } )
db.getCollection("_User").createIndex( { "_auth_data_facebook.id": 1 }, { unique: true, sparse: true } )
Would also need to add background: true if the database is live. Sparse is required if a login type is optional.
Because similar indexes already exist on _User, these will need to be dropped first:
db.getCollection("_User").dropIndex( { "_auth_data_anonymous.id": 1 } )
db.getCollection("_User").dropIndex( { "_auth_data_facebook.id": 1 } )
When the index is dropped there will be a collection scan on any query for anonymous/facebook id which I imagine would happen any time a signup happens so dropping the indexes may require downtime.
You can also change the index direction to -1 to avoid downtime. Then you can build the unique index before dropping the non-unique index, and the direction doesn't matter for unique indexes, so it works fine.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.