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:

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.

1 Like