reactioncommerce / meteor-security

A Meteor package: Logical MongoDB security

Home Page:https://atmospherejs.com/ongoworks/security

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility with CollectionFS

fusepilot opened this issue · comments

Images is an FS.Collection.

Images.permit(['insert']).apply() throws TypeError: Object #<EventEmitter> has no method 'permit'. No surprise since Images is not a Mongo.Collection.
Images.files.permit(['insert']).apply() seems to work.
Images.files.permit(['download']).apply() throws TypeError: Cannot convert null to object.

It would be great to be able to use these packages together in some fashion.

Same problem with me

That seems to occurs when is passed a method that doesn't are one of these 'insert', 'remove', 'update' to .permit()

We could try to make it work with extended like "download" eventually.

@fusepilot By now, this code had worked for me:

Images.files.permit(['insert', 'update', 'remove']).ifHasRole('admin').apply();

Images.allow({
    download: function(userId, doc){
        return true;
    }
});

I'm not sure that's the best solution, but it works at all :p

commented

Hi,

For my image collection this line:
ShopMediaFiles.files.permit(['download']).ifLoggedIn().apply();
still returns the following error:
TypeError: Cannot convert null to object
Can you tell me what am I doing wrong?

This line works perfectly: ShopMediaFiles.files.permit(['insert', 'update', 'remove']).ifHasRole('admin').apply();

Thanks.