Skip to content

Support merging multiple login services to a single account in a Meteor app.

Notifications You must be signed in to change notification settings

rkstar/accounts-multiply

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

accounts-multiply


This package allows you to support having multiple OAuth accounts from a single service under one user account in your Meteor application. With the ability to have multiple accounts from a single service, you can now build a Meteor app that can manage teams of social media accounts and connect infinite services and accounts to those services.

A bonus is you can allow login from any of the connected accounts and they will all authenticate to the same Meteor user account.

Installation

meteor add rkstar:accounts-multiply

Usage

This package is based on work done in splendid:accounts-meld and has improved upon many features of the previous version of this package.

To use accounts-multiply, simply install it from Atmosphere and continue to use Meteor.loginWith<ExternalService>(). Unlike mikael:accounts-merge, there is no callback option for the login functions. Instead, there is a server hook exposed that allows you to run arbitrary code after an account has been merged.

client

Meteor.loginWithTwitter()
Meteor.loginWithFacebook()
Meteor.loginWithGoogle()
...etc

server

In order to run code after an account has been multiplied/merged you can add to the onMultiply routines:

import {AccountsMultiply} from 'meteor/rkstar:accounts-multiply'

AccountsMultiply.onMultiply((owner, merged)=>{
  // owner
  // -> the originally logged in Meteor.users account
  
  // merged
  // -> the account that was merged into the 'owner' account
})

You can also set priority on the onMultiply hooks. If you set priority=true the hook will be placed at the front of the line when the hooks are run.

AccountsMultiply.onMultiply((owner, merged)=>{
  // i want this one to run before my other hooks!
}, true)

NOTE: setting "priority" will make your function run first if there are multiple routines. Multiple "priority" merge routines will be run LIFO

Notes

Thanks to splendido:accounts-meld and mikael:accounts-merge for fantastic templates for merging OAuth accounts.

About

Support merging multiple login services to a single account in a Meteor app.

Resources

Stars

Watchers

Forks

Packages

No packages published