Abhay
Abhay

Reputation: 23

How to set different rules for different collection

I want my application read only the language collection data from firebase before authentication only and read data from Users collection only when user is authenticated. enter image description here

my rules enter image description here

Upvotes: 0

Views: 98

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598740

As far as I can see, you're asking for:

service cloud.firestore {
  match /databases/{database}/documents {
    match /Language/{document} {
      allow read: if true;
    }
    match /Users/{document} {
      allow read: if request.auth != null;
    }
  }
}

With the above any user (regardless of their authentication state) can read the Language collection, but only authenticated users can read the Users collection.

Upvotes: 1

Related Questions