Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Method invoke context, need better way to set to Meteor.userId, for hooks #119

Open
zeroasterisk opened this issue Aug 22, 2016 · 5 comments

Comments

@zeroasterisk
Copy link

We are currently setting a "fake" invoke context here:
https://github.com/stubailo/meteor-rest/blob/devel/packages/rest/rest.js#L199-L222

This works well enough for the Method call, but not for anything subsequent... for example, when using Meteor Collection Hooks, it is not able to determine the userId
https://github.com/matb33/meteor-collection-hooks/blob/master/collection-hooks.js#L28-L51

I tried to wrap addHTTPMethod and it's inner handler function in Meteor.bindEnvironment but since it's a fake context anyway, I don't think it did anything for me.

I tried to set Meteor.userId = userId but that didn't seem to help much either (and kinda freaked me out).


Is there some means of either setting up a better and more rhobust Meteor context in the REST API, or perhaps telling MeteorCollectionHooks about how to find the userId set into the method's context, but not available to the collection's context.

?

@zeroasterisk
Copy link
Author

Here's a fully demonstrating test repo:
https://github.com/zeroasterisk/meteor-rest-and-collection-hooks

Just clone and start meteor, it creates a user, a doc, and uses HTTP to login, and then attempt the method...

It shows that method works fine, and is authenticated, but the collection hook does not.

thoughts?

crosspost to Meteor-Community-Packages/meteor-collection-hooks#178

@hluz
Copy link

hluz commented May 22, 2017

@zeroasterisk did you (or anyone else listening) found any workable solution for this issue?

@zeroasterisk
Copy link
Author

No not really.

@hluz
Copy link

hluz commented May 23, 2017

Maybe this will fix it: #118

@dpatte
Copy link

dpatte commented Jun 16, 2017

yes, there is a pull request 118 that fixes the same problem in simple:rest, and which works for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants