diff --git a/packages/accounts-base/accounts_server.js b/packages/accounts-base/accounts_server.js index eca4c3e5a8..1dfb05d6a7 100644 --- a/packages/accounts-base/accounts_server.js +++ b/packages/accounts-base/accounts_server.js @@ -77,9 +77,9 @@ export class AccountsServer extends AccountsCommon { // user expects. The way to make this work in a publish is to do // Meteor.find(this.userId).observe and recompute when the user // record changes. - var currentInvocation = DDP._CurrentInvocation.get(); + const currentInvocation = DDP._CurrentInvocation.get() || DDP._CurrentPublicationInvocation.get(); if (!currentInvocation) - throw new Error("Meteor.userId can only be invoked in method calls. Use this.userId in publish functions."); + throw new Error("Meteor.userId can only be invoked in method calls or publications."); return currentInvocation.userId; }