ant45de
ant45de

Reputation: 822

Meteor how to debug allow/deny

I'm working on my meteor project and started setting up one of my first more complex allow/deny rules. I find it quite hard to see which allow triggered and which not and what some variables inside these functions contain. For example:

List.allow({
   update: function(userId, docs, fields, modifier) {
       if(!docs.user){
           console.log("list without owner => updateable for everyone");
           return true;
       }
       else if(userId === docs.user){
           console.log("user is owner of list => updateable!");
           return true;
       }
       else {
           console.log("no access, is not owner");
           return false;
       }
   }
});

The console.log statements do not work (nothing is logged in the console). I'd like to know what docs, fields and modifier contains in the moment the allow-rule is checked to adjust my code. How can I debug in these methods? If not, can somebody correct my code? I have a Collection where Meteor.users can have his own record, this should only be updat

Upvotes: 0

Views: 44

Answers (1)

gatolgaj
gatolgaj

Reputation: 1203

Use meteor debug instead of meteor run to start your meteor application. It will add the node inspector package to your running Meteor app so that you can debug it.

Also you can use Meteor Shell in the CLI.

For More info Josh Owen's blog

Upvotes: 1

Related Questions