diff --git a/server.js b/server.js index 7cd6ff8..a342d67 100644 --- a/server.js +++ b/server.js @@ -28,10 +28,10 @@ CollectionHooks.getUserId = function getUserId () { const _publish = Meteor.publish Meteor.publish = function (name, handler, options) { - return _publish.call(this, name, function (...args) { + return publishUserId.withValue(this && this.userId, () => _publish.call(this, name, function (...args) { // This function is called repeatedly in publications - return publishUserId.withValue(this && this.userId, () => handler.apply(this, args)) - }, options) + return handler.apply(this, args) + }, options)) } // Make the above available for packages with hooks that want to determine