gwendall:accounts-helpers

v0.1.6Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

This package provides helpful helpers to deal with users.

Installation

meteor add gwendall:accounts-helpers

Client methods

Accounts.onLogin(cb)

Hook for user log in.

1Accounts.onLogin(function() {
2  console.log('You are logged in.');
3});

Accounts.onLogout(cb)

Hook for user log out.

1Accounts.onLogout(function() {
2  console.log('You are logged out.');
3});

Accounts.onConnect(cb(provider))

Hook for user connection to a social account when already logged in.
Requires splendido:accounts-meld.

1Accounts.onConnect(function(provider) {
2  console.log('You have connected your ' + provider + ' account.');
3});

Accounts.onDisconnect(cb(provider))

Hook for user disconnection from a social account when already logged in.
Requires splendido:accounts-meld.

1Accounts.onDisconnect(function(provider) {
2  console.log('You have disconnected your ' + provider + ' account.');
3});

Accounts.disconnect(provider, cb)

Disconnect a social account.
Requires splendido:accounts-meld.

1Accounts.disconnect('facebook', function() {
2  console.log('You have disconnected your Facebook account.');
3});

Client template helpers

1  <button data-accounts-loginwith={{provider}}>Login with {{provider}}</button>

Logs in the user with a given provider.

1  <button data-accounts-disconnect={{provider}}>Disconnect {{provider}}</button>

Removes the given provider's credentials from the user.
Requires splendido:accounts-meld.

1  <button data-accounts-logout>Log out</button>

Logs the user out.

Server methods

Accounts.onJoin(cb(data))

On user joins for the first time. The hook does not get triggered when Accounts.createUser is called with no client / user intent.

1Accounts.onJoin(function(data) {
2  console.log('A user has joined from ' + data.type);
3});

Accounts.disconnect(userId, provider)

Disconnect an account provider.
Requires splendido:accounts-meld.

1USER_ID = '...';
2Accounts.disconnect(USER_ID, 'facebook');