Little BackGround: I have two app (app1 & app2). From app1 one user can register themselves. After logging in to app1 user can give their data in an input field which will be saved in a notes collection.
From app2 user can see their notes which I have done it through DDP and subscribe.
Now my task is:
from app2 users(app1 users who registered already) can log in if they are logged out from app1 and can see their own data. For that, I was trying to publish Meteor.users from app1 and trying to subscribe this from app2. but unfortunately, I am not able to fetch the users data.
here is the code in the server side in app1
app1/server/main.js
Meteor.publish('usersData', function () {
if (!this.userId) { //if user is not logged in app1 then publish
return Meteor.users.find({ });
} else {
this.ready();
}
});
from app2 i was trying to fetch the data through subscribe:
app2/clint/main.js
let conn = DDP.connect('http://localhost:3000/')
Notes = new Mongo.Collection('notes', conn)
UserData = new Mongo.Collection('usersData', conn)
Template.body.onCreated(function bodyOnCreated () {
conn.subscribe('usersData');
conn.subscribe('db1') // subscribing for users Notes and successed
})
with mesvin/Mongol-meteor-dev tool i could see the users data but could see the registered data in app2.
Please let me know how can i overcome this problem ?
Later on, I was trying to log in with ddp-login and it says the password is invalid.