How to change DDP userId?


#1

I creating custom accounts package and i need to set userId of DDP connection after login successful.

I using this method to do that:

Meteor.connection.setUserId(userId);

But i can’t use it in publishcation methods:

Meteor.publish('jobs', function(options){
    console.log(this.userId); // <= NULL
});

Anyone can help me?


#2

You have to call this.setUserId on server. See: https://github.com/gwendall/meteor-impersonate/


#3

Thankyou so much. Solved !