Remote users collection with multiple apps


#1

Is there a way to have multiple meteor apps and share only the users collection from one app? To me clear I don’t want all my apps to use the same mongo database. I want them to all have their own individual databases and use one of the app’s users collection to authenticate against.

Currently I am doing this:

__meteor_runtime_config__.ACCOUNTS_CONNECTION_URL = 'http://myurl';

if (Meteor.isClient) {

  Meteor.startup(function() {
    var token = Accounts._storedLoginToken();
    console.log(token);
     if(token)  {
       Meteor.loginWithToken(token, function(err){
        // this is going to throw error if we logged out
        if(err)
          console.log(err);
        else
          console.log('loginWithToken');
      });
     }
  });
}

Which is working on the client, but I have server side code that isn’t working in a publication. The user is null?

Meteor.publish('modules', function() {
    var user = this.userId;
    // This is null here...
  });
}

I think I’ve read about every article on the topic about Accounts in Meteor and I’m confused to say the least. AccountsCommon, AccountsClient and AccountsServer aren’t very clear.

Any help is appreciated…