matheusccastro:append-to-connection

v1.0.1Published 4 years ago

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

meteor/append-to-connection

As SockJS doesn't allow us to pass cookies and/or other data to the connection, we have to manually do that by calling a method to the meteor server. This is specially useful for cordova in multi tenant apps. This package is just a helper to do that.

Note: don't use this for authentication. This should be used just for scopes/identification.

Usage

AppendToConnection.register register your hook. You must return an object with the fields you want to append.

import { AppendToConnection } from "meteor/matheusccastro:append-to-connection";

AppendToConnection.register(() => {
    // your function here
    return {};
});

There are two types of hooks, the onConnection hook and the onLogin hook. You register both the same way, but the onLogin hook has different parameters:

// onLogin -> To know what is what, check the onLogin meteor docs: https://docs.meteor.com/api/accounts-multi.html#AccountsCommon-onLogin
AppendToConnection.register(({error, loginDetails}) => {});

// onConnection
AppendToConnection.register(() => {});