I have created an user on the dashboard (with Username-Password-Authentication, which is the only authentication method possible). I also enabled Microsoft social connection. Basically, I would like to give our users the option of being able to log in with username/password, and if they sign in using any social connection we have enabled, then I would like to automatically transfer over their account from Username-Password-Authentication to the social account (including any values in user_metadata and app_metadata).
Is this possible? Since i found if i connect using any social connection, it’ll just create a duplicate user with the same email.
I haven’t tested it, but I’m pretty sure there’s a slight error in it. In the docs they tell you to user context.primaryUser to switch the current login to the new merged account. However, in my testing I’ve noticed you need to also set the user object to the new merged account.
Basically, if you find that the above sample code doesn’t work as expected, changing
context.primaryUser = originalUser.user_id;
to
context.primaryUser = originalUser.user_id;
user = originalUser;