matteodem/meteor-easy-security

Server error message when easy-security was installed

rnarayan opened this issue · 5 comments

We are on Meteor release 1.0.2.1 . After installing easy-security, we get the following error when trying to start the app. Without easy-security, the app is error-free.

Exception in setTimeout callback: Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
at Object.Meteor.userId (packages/accounts-base/accounts_server.js:19:1)
at [object Object].Meteor.methods.reverify (app/server/collections/users.js:98:16)
at [object Object].methodMap.(anonymous function (packages/meteorhacks:kadira/lib/hijack/wrap_session.js:182:1)
at Object.methods.rateLimit.callFunctionsInQueue (packages/matteodem:easy-security/lib/easy-security.js:72:1)
at packages/matteodem:easy-security/lib/easy-security.js:116:1
at packages/matteodem:easy-security/lib/easy-security.js:92:1
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at packages/meteor/timers.js:6:1
at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)

Do you have a little reproduction repo or steps to reproduce it?

Unfortunately not. It's quite a big project by now and is in a private repo. Sorry about that.

For some reason, it doesn't like the use of Meteor.userId() on server side methods. I can change that to this.userId in my custom methods but, as shown by error message, several packages use Meteor.userId() too, which we can't change.

Also to clarify, the error posted above is a warning message. The app does start and in our limited testing after adding easy-security, everything worked fine and nothing seemed broken.

Let me know if you would want me to close this issue. Thanks a lot.

I understand that, but as I had it in my mind it always throw's that error. It's weird that it wouldn't do it without it because inside of Meteor.methods you can only use this.userId as documented here http://docs.meteor.com/#/full/meteor_methods. I will investigate further otherwise, let's have this open for now.

Please let me know what packages cause this error, otherwise I won't know how to test this.

change all Meteor.userId() to this.userId on the server code and this error goes away