Situation:
- User A registers an account in our application and logs in.
- For what ever reason logs out.
- Logs in to the application again using Facebook social sign on with an account that has the same email associated with it as the original registration had.
- A second account is created for this sign on and 2 accounts exist in the system.
How can I merge these accounts into a single account during the social sign on (by querying for the existence of that email) automatically or with User Collection Business Hooks (if with business hooks, can you please provide an example of how I would do this as documentation online is unclear for this specific purpose).
Notes:
- Kinvey backend
- Phonegap with facebook plugin
- Jquery mobile
- Wish to merge accounts or find existing account and add social identity to it during sign on
- Assume I cannot delete users
- Preferably achieve this step with a PreSave Kinvey Business Logic Hook
Cheers,
I managed to create my own custom end point to basically achieve user merging.
If a user exists with a kinvey account, then tries to log in using facebook with an email address matching a kinvey user, I used the following end point code to add a social identity to the existing user before attempting to log in using that user (This function only worked because we maintain a guest login for users not logged in to the system).
Hope this helps some one.