Insert failed: Access denied


#1

I want to insert a piece of data (let’s say, a post) in my database. I called Posts.insert() on the client side and I get this message in my browser console “insert failed: Access denied”.
I added Post.allow :

Posts.allow({
insert: function (userId, doc) {
return true;
}
});

But I still have the same message. So what I have to do ?


#2

Have you put that allow rule in your server code?


#3

I have to put it in server code ?


#4

Yes. Server code cannot be tampered with, so it’s the only place you can “open holes”.

Edit: I should add that it’s hard to write good allow/deny rules and it’s usually much easier (and safer) to call a Meteor method.


#5

Working now by changing Post.allow in the server side.
Thank you ^^