How can I get the useraccounts package to write a new user doc to a remote collection?

I’m using accounts-password and useraccounts:bootstrap and it all works fine, meaning the sign-on form creates a new doc in the Meteor.users collection. But I don’t want any collection on the client facing app, hence I do have a second app running to which I successfully connect via DDP.connect() and I can exchange all necessary docs/collections via pub/sub and calling methods on the remote app.

The only thing that doesn’t work is the useraccount doc. I’ve used (on the client app):

remote.subscribe('users', Meteor.userId(), function() {

and (on the remote app):

Meteor.publish('users', function() {
    return Meteor.users.find({});

even though I’m not sure if there is a pub/sub already included in the package. Still, the doc is written to the local (client) app and not to the remote app.

How can I achieve this?

Also on SO:

useraccounts:core simply makes use of Accounts.createUser on the server side (see this line) within a method called from the client-side (see this another line).
So the new user object is created from the server side and not from the client (though it flows all the way down to the client thanks to the DDP and default users subscriptions…).

If you’re really looking to change the defaul behaviour provided by the Meteor core Accounts packages (accounts-base, accounts-password in this case…) you should try to override the Accounts.createUser method which is were all begins…

In any case be warned that the current user is published to the client by default: see these lines

Finally, to prevent useraccounts:core to use the Accounts API you could try to override the AtCreateUserServer method and deal with the creation of a new user on a remote application inside there.

1 Like

Thanks Luca!

as I’ve never overridden someone else’s code/package, would this be the correct way to do it?

  1. use git to make a local copy of accounts-base
  2. copy the method ATCreateUserServer from server_methods.js into my remote app
  3. replace this line return"ATCreateUserServer", options, function(error) in at_pwd_form.js with a by the same name to redirect it to the method on my
  4. Use the already pub/sub of the Users collection that I outline in my original post

Would it be correct to replace the at_pwd_form.js in my local version of accounts-base which would be based in the .meteor\local\packages within a folder of the name of accounts-base?

Or what do I do with my changed file?