Accounts-password + accounts-ui + remote users trought DDP

Hi,

I have 2 meteor apps, one server and other web
on server installed accounts-password
on client installed accounts-password and accounts-ui

PROBLEM: After creating and login a user with Accounts ui widget the user isnt logged in in the UI (i still seeing the sing in link instead of the username).

The user is stored ok in the remote collection, i dont know how to solve this.

Extra data:

// server
    Meteor.publish('users', function() {
        return Meteor.users.find({_id: this.userId}); //this works OK, if i query the user collection before login this will be empty
    });

// client
 Meteor.connection = DDP.connect('http://localhost:3000');
 Accounts.connection = Meteor.connection;
 Meteor.users = new Meteor.Collection('users');
 Meteor.connection.subscribe('users');

if i make a click event in the client, i get:

console.log("+++++ Meteor users +++++");
Meteor.users.find().forEach(function(i){
  console.log('_id: '+ i._id); // valid ID of the logged in uer, only 1 id its showed, the current user
}) 
console.log("+++++ User data +++++");
console.log("Meteor.userId(): "+Meteor.userId()); // current user id
console.log("Meteor.user(): "+ Meteor.user()); **//undefined :(**

Any help its appreciated, im just starting with meteor with DDP so any tips/best practice, etc will be very appreciated.

I tried the package useraccounts with the same results, Meteor.user() its undefined always and that seems to be the reason for the missing UI changes… any help?

You may try this solution:

Check out the new documentation for accounts with multi-server. It is missing an example, unfortunately.

1 Like

i dont want to sound rude, and i appreciate a lot the answers, thanks a lot really @XTA, @jamgold for your time.

its a pain make this work on DDP, i cant undestand why its so hard to work the accounts-base with packages like accounts-passwords , the packages must work without any problem even if im using DDP, all the collection works, i can set perms, pub/subs, and execute remote methods, but this issues using packages with the accounts system its making me leave this to make MVPs.

I readed all the Accounts docs and multiserver, but it has no sense that having alot of packages in atmosphere a developer must waste a lot of time making the register-login process from the scratch, any decent framework/platform has this working from scratch with roles and so on.

1 Like