Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DDP.connect and Meteor.users

Tags:

meteor

ddp

I am in the process to try to separate out the mobile from the desktop part of my application and thought I try DDP.connect as a means for the mobile application to share data with the desktop application.

My first hurdle is concerning Meteor internal collections and publications.

How am I supposed to authenticate users? I know I can call the login method to authenticate a user, but that still doesn't give me all the other nice reactive features I am used to with Meteor.users

Is this supposed to work, and if so what is the pattern.

Thanks

like image 291
Jamgold Avatar asked Sep 01 '26 13:09

Jamgold


1 Answers

This is what integrated completely with a remote server (except code refresh, which forgets user session)

if (Meteor.isClient) {
 Meteor.connection = DDP.connect('http://remote.site.com');
 Accounts.connection = Meteor.connection;
 Meteor.users = new Meteor.Collection('users');
 SomeCollection = new Meteor.Collection('remote_collection');
 Meteor.connection.subscribe('users');
 Meteor.connection.subscribe('remote_collection');
 // rest if the code just as always
}

This way you can use login directly (via accounts-base, accounts-passed, etc) and don't need to call a login method. Just add accounts-ui and include {{>loginButtons}} and it works

like image 144
Jamgold Avatar answered Sep 05 '26 17:09

Jamgold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!