Reaction Commerce Forums

How to incorporate a new authentication provider


I want to create a new authentication provider that uses our own in-house authentication service. This would be similar to any of the accounts-* (e.g. accounts-password) meteor packages. I’ve found a tutorial on how to create a Meteor package to do this, but I’m not sure the best way to go about incorporating it into Reaction Commerce. Do I need to write an RC plugin that does the same thing as the Meteor package? Or should I somehow include a local Meteor package?

Just to get started, I tried creating a plugin and added the following code to …/custom/myplugin/server/init.js

import { Hooks, Reaction, Logger } from "/server/api";
import { Accounts } from "meteor/accounts-base"

function addINITAuthentication() {"!!! Adding INIT Authentication support !!!");
  Accounts.registerLoginHandler("INIT Auth", function(options) {"!!! Called INIT Login handler with options = ", options);
    return undefined;

Hooks.Events.add("afterCoreInit", () => {

I see the first Log message and so it looks like my plugin is correctly registered. However, during login, my login handler is never called.



So it appears I didn’t quite understand how login works in Meteor. Each login handler is called in turn until one of them handles the login and returns a result. When this happens, the loop is exited and the other login handlers are not called. So I’m assuming that my handler wasn’t called because the handler from accounts-password was handling the login.

I’m assuming I either need to remove the accounts-password package or find some other way to intercept the login. If I remove the accounts-password package, then I think I lose the accounts-ui package as well. So still not sure what the best way to go about this is.


@blevine218 Do you succeed on this? I am facing the same problem. We need to integrate Reaction into our existing account system (no meteor stack) and we need to write a authentication provider like you did.

@aaronjudd any advice on how we gonna make it?