nanobar
nanobar

Reputation: 66355

Firestore publicly writable collection

When a user is created I need to add some additional data about the user (e.g. name).

So I need a publicly writable collection. However I've tried adding create and update (I think that's for set and add respectively), but I'm still getting "Error: Missing or insufficient permissions." when trying to do:

db.collection('newUsers').add({
  firstName,
  lastName,
});

With this rule:

service cloud.firestore {
  match /databases/{database}/documents {
    match /newUsers {
      allow create, update;
    }
  }
}

How can I add an entry to that collection without being authed?

Upvotes: 2

Views: 56

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317392

service cloud.firestore {
  match /databases/{database}/documents {
    match /newUsers/{user} {
      allow create, update if true;
    }
  }
}

Note that you need to match an actual document, not just a collection. The wildcard {user} should do this.

Upvotes: 2

Related Questions