Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
657 stars 92 forks source link

Difference between anonymous user and server-invoked operation? #212

Closed Kshatra closed 7 years ago

Kshatra commented 7 years ago

How can i differentiate between anonymous user and server-invoked operation in a hook? In both cases userId would not be defined. I'm trying to use hooks as permission filter to lessen permission check code in each publication/method (is this a good idea?)

For example, i have a server code that make some collection operations on each start of the server. But anonymous users cannot be allowed to make these operations. How to write an operation hook in this case?

zimme commented 7 years ago

First thing that comes to mind is some package that assigns anonymous users to non-logged in users and with that package you should be able to differentiate between server- and anonymous-invoked operations.