Ad

How To Set Firebase Cloud Firestore Security Rules With Firebase Authentication

I have created a database cloud firestore. In this database I want anyone to be able to read and write if: request.auth.uid != null now an facing a permission problem when someone is trying to login or sign up using email and password with firebase authentication. I get insufficient permission. How can I let any of my users sign up and login at the same time protect the other part of the database

Ad

Answer

This rule should be good enough.

service cloud.firestore {
  match /databases/{database}/documents {    
    match /YOUR_COLLECTION_NAME/{doc} {
       allow write, read: request.auth.uid != null
    }
  }
}

But are you sure you are setting your authentication properly?

Check Authentication -> Sign-in Method and make sure you enable the providers you need. Using the Firebase sdk for auth you will be able to pass this validation after you log in your user. Take a look a this

Ad
source: stackoverflow.com
Ad