Connect service to existing meteor account

Viewed 1973

I am setting up a meteor app that involves signing up with a username and password, then hopefully connecting that account with facebook and twitter.

I have the first part up and running easily, just with the accounts package. But when I have a logged in user call Meteor.loginWithFacebook(), it logs them out and creates a new account. What I want is something that adds the facebook credentials to the currently logged in user.

The meteor docs have this:

{
  _id: "bbca5d6a-2156-41c4-89da-0329e8c99a4f",  // Meteor.userId()
  username: "cool_kid_13", // unique name
  emails: [
    // each email address can only belong to one user.
    { address: "cool@example.com", verified: true },
    { address: "another@different.com", verified: false }
  ],
  createdAt: Wed Aug 21 2013 15:16:52 GMT-0700 (PDT),
  profile: {
    // The profile is writable by the user by default.
    name: "Joe Schmoe"
  },
  services: {
    facebook: {
      id: "709050", // facebook id
      accessToken: "AAACCgdX7G2...AbV9AZDZD"
    },
    resume: {
      loginTokens: [
        { token: "97e8c205-c7e4-47c9-9bea-8e2ccc0694cd",
          when: 1349761684048 }
      ]
    }
  }
}

which appears to be an account with a username that's also authenticated with Facebook. But I'm not sure if that's just an example that you can't actually achieve with basic Meteor stuff.

What I am trying to make is basically

Meteor.connectWithExternalAccount();

which runs the same process as Meteor.loginWithExternalAccount(), but just adds the information to the currently logged in user.

If someone could just explain the accounts-base package a bit so I could know where to start for myself that would be great.

Also, does anyone know if this will be included in any future versions of Meteor?

2 Answers
Related