Add this.publishAuth next to this.userId

Hi, I want to have a 2nd authentication inside my all of my publish methods without having to do a db lookup every time. So I have tried adding a this.publishAuth which is tied to a connection to be reused like the userId.

In my publish I call the auth method:

const invocationData = {
      userId: userId,
      connection: this.connection,
      publishAuth: this.publishAuth
    };"publishAuthCheck", invocationData, "abc123");

In the above log prints is undefined.

I try to create publishAuth like this:

import { Meteor } from 'meteor/meteor';
import { DDPCommon } from 'meteor/ddp-common';

Meteor.startup(function () {
  _.extend(DDPCommon.MethodInvocation.prototype, {
    setPublishAuth: function (publishAuthResult) {
      this.publishAuth = publishAuthResult;

  publishAuthCheck (invocationData, someId) {
    check(invocationData, Object);
    check(someId, String);

    invocationData["randomSeed"] = this.randomSeed;
    invocationData["isSimulation"] = this.isSimulation;
    invocationData["_unblock"] = this._unblock;
    invocationData["_setUserId"] = this._setUserId;

    const invocation = new DDPCommon.MethodInvocation(invocationData);
    DDP._CurrentInvocation.withValue(invocation, () => {

this logs:

{ isSimulation: false,
_unblock: [Function],
_calledUnblock: false,
userId: null,
_setUserId: [Function],
connection: null,
randomSeed: ā€˜3019ga454dd571d04d62ā€™,
randomStream: null,
publishAuth: ā€˜33522d0cbf98eedd8abead0dā€™ }

userId and connection turns null and publishAuth exists only in this method call.