Hey guys,
is it possible to connect to another Meteor application on server side and call the login method (f.e. loginWithPassword)? Currently I’m only able to establish a connection like this:
You want to be able to connect and login to another Meteor server from the client perspective, right?
If yes then you have to create a new instance of AccountsClient and provide the created DDP connection to it.
For example:
Meteor.remoteConnection = DDP.connect('https://www.mainapp.com')
Meteor.remoteUsers = new AccountsClient({ connection: Meteor.remoteConnection })
After this you will have another working instance of accounts.
Unfortunately the instance won’t give you a method like Meteor.loginWithPassword.
You can check the implementation of the original method here: Meteor source code
Since I also wanted to be able to have loginWithPassword method for my secondary accounts I just copied the existing implementation and changed the Accounts.callLoginMethod to my Meteor.remoteUsers.callLoginMethod.
What exactly gave you this result? Was it calling the loginWithPassword method ? According to the documentation it should either doesn’t return anything or return an error if it failed to login.
You should be able to see if you were logged in successfully by running in your console:
Meteor.remoteUsers.user() (if you followed the steps from my first reply) which should give you the record of your user connected to the other server. You can also check that in backend logs or MongoDB users collection.