Meteor.signInWithFacebook = function (options, callback) {
  Meteor.signInWithExternalService ('loginWithFacebook', options, callback);
};

Meteor.signInWithTwitter = function (options, callback) {
  Meteor.signInWithExternalService ('loginWithTwitter', options, callback);
};

Meteor.signInWithGoogle = function (options, callback) {
  Meteor.signInWithExternalService ('loginWithGoogle', options, callback);
};

Meteor.signInWithLinkedin = function (options, callback) {
  Meteor.signInWithExternalService ('loginWithLinkedin', options, callback);
};

Meteor.signInWithGithub = function (options, callback) {
  Meteor.signInWithExternalService ('loginWithGithub', options, callback);
};

Meteor.signInWithExternalService = function (service, options, callback) {

  var oldUserId = Meteor.userId();
  var oldLoginToken = Accounts._storedLoginToken();

  Meteor[service]( function (error) {

    if (error) {
      if (typeof callback === 'function') callback (error);
      return;
    }

    var newUserId = Meteor.userId();

    // Not logged in, logging in now.
    if (!oldUserId) {
      if (typeof callback === 'function') callback ();
      return;
    }

    // Login service has already been added, just logging in
    if (newUserId == oldUserId) {
      if (typeof callback === 'function') callback ();
      return;
    }

    // Adding the new login service
    Meteor.call ('mergeAccounts', oldUserId, function (error, result) {

      if (error) {
        if (typeof callback === 'function') callback (error);
        return;
      }

      // Log out the source user
      Meteor.logout ( function (error) {

        if (error) {
          if (typeof callback === 'function') callback (error);
          return;
        }

        // Log back in as the original (destination) user
        Meteor.loginWithToken( oldLoginToken, function (error) {
          if (error) {
            if (typeof callback === 'function') callback (error);
            return;
          }
          if (typeof callback === 'function') callback (undefined, newUserId);
        });
      });
    });
  });
};

@@ -1561,49 +1561,94 @@
 Log 
-out the source user%0A      Meteor.logout (
+back in as the original (destination) user%0A      Meteor.loginWithToken( oldLoginToken,
  fun
@@ -1659,25 +1659,24 @@
 n (error) %7B%0A
-%0A
         if (
@@ -1780,255 +1780,8 @@
   %7D%0A
-%0A        // Log back in as the original (destination) user%0A        Meteor.loginWithToken( oldLoginToken, function (error) %7B%0A          if (error) %7B%0A            if (typeof callback === 'function') callback (error);%0A            return;%0A          %7D%0A  
     
@@ -1857,20 +1857,8 @@
 d);%0A
-        %7D);%0A
     

Remove not needed logout