meteor-rest icon indicating copy to clipboard operation
meteor-rest copied to clipboard

Meteor.userId throwing error on method call

Open nelson-uruworks opened this issue 9 years ago • 12 comments
trafficstars

Hi, I'm using simple:rest-accounts-password to authenticate the users, and when I make a call to one of my methods that makes use of Meteor.userId() using POST to /methods/myMethodName I get the following exception:

Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.

If I use this.userId, I get a correct identification, but that shouldn't be the way of using it inside a meteor method. Am I missing something? Thank you.

nelson-uruworks avatar Nov 15 '16 15:11 nelson-uruworks

I also have this issue. See #54

dpatte avatar Nov 15 '16 15:11 dpatte

oh okay I see, thank you for replying

nelson-uruworks avatar Nov 15 '16 17:11 nelson-uruworks

there is a pull request which resolves this issue

dpatte avatar May 22 '17 22:05 dpatte

I have the same problem. Has any solve?

thearabbit avatar Jun 15 '17 09:06 thearabbit

yes, the pull request solves this issue.

dpatte avatar Jun 15 '17 12:06 dpatte

Merge already? I still have this problem.

thearabbit avatar Jun 16 '17 01:06 thearabbit

the pull request means that it is not yet merged. you will have to merge it yourself locally or wait for it to be merged.

dpatte avatar Jun 16 '17 01:06 dpatte

Thanks again, what #... of pull?

thearabbit avatar Jun 16 '17 04:06 thearabbit

Also having this issue... any ideas?? WE only use OAuth logins - Facebook and Spotify currently. Adding the simple:rest-accounts-password package didnt fix it. Using simple:rest 1.1.1

MileanCo avatar Oct 13 '17 09:10 MileanCo

This issue still hasn't been resolved. For those wondering why, it is essentially stuck on an old meteor method api whereby instead of allowing Meteor.user() or Meteor.userId() to be resolved it instead is setting this.userId. So you can use this.userId in the meantime, but not ideal if you want your methods to also work as normal methods.

jmarks-joshua avatar Mar 23 '18 13:03 jmarks-joshua

Is this going to be merged soon?

convexset avatar Aug 09 '18 07:08 convexset

I notice that Fiber.current._meteorDynamics is not defined so a quick hack would not be possible.

convexset avatar Aug 09 '18 07:08 convexset