meteor/meteor — pull request #1133 by yubozhao (2013-06-08 01:12:52+00:00)
Title: Link accounts to meteor user

#Problems: #
Meteor account system is currently not supporting the ability to link different external services account(such as Twitter, Facebook) to the same Meteor user. A real life example would be Instagram, where Instagram links different social network accounts with the Instagram account to provide user ability to share pictures over different social networks.

#Possible solutions#
Running along with Meteor's existing account system and handles the issue when calling the login method (Another Account registerLoginHandler).
Build a link system that is separate from existing login system. It should simplify some process because it is not login, but link.

#Solution we choose:#
We choose to build a link system that is separate from existing login system, because we felt the features we add on are extend features, not basic. And they should be kept in separate section and have rooms for potential expansion in features. Also, it might be confusing to developers that use loginWith to connect additional services.

#What accomplished in this pull request:#
##if user were first use external service to register Meteor user:##
1. User can link and unlink different external service, that is not what user already register with.
2. User can log in this Meteor account with different external service that is linked to the Meteor account.
for example: user first register Meteor account with facebook account, later on he linked his instagram account. Now he can login this Meteor account with either facebook or instagram accounts that was already linked with Meteor account.
3. User can link password based account to Meteor user (that was created by external service).
User can log in with the password with that linked Meteor user.

##if user were first use password based to register Meteor user:##
1. User can link and unlink different external service.
2. User can log in this Meteor account with different external service that is linked to the Meteor account

#Error Codes#
90000 - "You must be logged into an existing account to link a service."
90001 - "Another user already exist with this service!"
90002 - "Attempt link service already exist."

90003 "You must login to unlink a service."
90004 "You can't unlink password service"
90005 "You can't unlink a non-existing service."
90006 "You can't unlink the only service"

![lnkchart](https://f.cloud.github.com/assets/670949/626882/3c1fea46-cfd8-11e2-989c-39751f5cf430.jpg)