foobarbecue
foobarbecue

Reputation: 7070

Handling "access denied" in meteor

In Meteor, if the client tries to insert, update, or remove a database document and they aren't allowed to, "insert failed: Access denied" appears in the console. Instead of that silent message, I'd like to run some client-side javascript each time that occurs.

Is there a way I can attach a handler function to the "access denied" event / exception?

Upvotes: 3

Views: 202

Answers (1)

David Weldon
David Weldon

Reputation: 64342

The collection functions have callbacks that contain the information you need. Let's use insert as an example:

Posts.insert({message: 'hello'}, function(err, id) {
  if (err) {
    alert('failed to insert post!');
  }
});

Upvotes: 4

Related Questions