Can't Meteor.loginWithFacebook if email already registered

Hello!

I want to have bolth e-mail login and FB login at the same time available for clients. The problem is, that If I have a registered user with Accounts.createUser({ email, password })Meteor.logout() → Try to Meteor.loginWithFacebook() and attempt to do it with user, that has the same e-mail, upon method call it throws “Email already exists”, meaning, that it tries to register the user.

What I would like it to do in this scenario, would be, that it finds that there is a user already with the same e-mail, and it would add the “facebook” section to users “services” in MongoDB, and log the user in.

Does anyone have a solution to this problem? Thanks! :slight_smile:

1 Like

Hi! I think you are looking for Accounts.setAdditionalFindUserOnExternalLogin().

If you look at the example in that link, you can match the user by email no matter which service they are using to login.

2 Likes

Oh snap… I never knew about this. For years, my users have only been able to add Sign In With Facebook once! :stuck_out_tongue_closed_eyes: And never a password and Facebook at the same time!

This little hook is amazing. When was this added?