I have two meteor apps that use the same database, one is a mobile app (primary) and the other is a desktop app.
From the desktop app, I would like to call the remote mobile method to create a listing so that I don't have to duplicate code 'Listing.create'
.
I was under the assumption that my logged in Meteor.userId
on the desktop app would be transferred while calling the remote mobile method, but this is not true, as it is undefined.
I also have Oauth and Email auth, and there doesn't seem to be an easy way to login using OAuth (logging in via call 'login' works well for passwords).
What's the best way to call the remote method since it fails without being logged in? I suppose I could pass in the userId as a string but that would open the method up to hacking
Mobile server, m.foo.com, MONGO_URL bar.com
Meteor.methods({
'Listing.create': function(){
if (!this.userId) throw new Meteor.Error(503, 'No user account');
...
db.listings.insert(...);
}
})
// on client
Meteor.userId() // 1234
Desktop server, foo.com, MONGO_URL bar.com
MobileDDP = DDP.connect('http://m.foo.com')
MobileDDP.call('Listing.create', function(err, res) {
console.log(err, res)
});