How can I set the Firebase Firestore rules if I want the user can access even there's no current user

Murad Ismayilov

I'm using Firebase Firestore to collect user information in my current Android app. But I didn't quite get the Firestore rules. I write the rule like this:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

But I want to user access the database even there's no current user because when the user sign up I'm checking the database if there's a current phone number in the database if not user can sign up this phone number. Thank you

Kundan
// Allow read/write access to all users under any conditions
// Warning: **NEVER** use this rule set in production; it allows
// anyone to overwrite your entire database.

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

Not recommended: Read and write access to all users.

Have a look at Fix insecure rules documentation from firebase for more details.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I set security rules for Firebase DB so that no user can make unauthorized requests to DB?

How can I check whether one's current User Points are negative with the Rules module?

How can i make user post public in the firebase rules

How can I ban a User in Firebase realtime Database using the rules?

How can I access the current user's roles in Orchard from a view page?

How can I set Rules in Firebase so that only my app can write on my database firestore?

How can I access a user from Firebase by UID?

How can I get the current user's username in Bash?

How can I get current user's JWT informations?

How can I display current user's name on display?

How can i get the user's current voice channel ID?

How can I access the number of the dataProvider's current data set?

How can I access the fields in firebase firestore?

how can I display all users except current user and current_user's friends in ruby on rails

How can I set a user's display name and email with Firebase signInWithCredentials()

Firebase rules: where can I find the user to which a id belongs to?

how can I read and write as an admin even if the rules set to false in Firebase Realtime Database

How can I save user's followers in firebase? React Native

How can I check if user exists in Firebase?

How can I retrieve Firebase user properties?

I have firebase user id, but I can't access name

How can i set the current values of a form field say a profile updating form with current user details

I want a user to only access download url for pdf if the user exists in order table models how can I do it?

How can I set the User Agent in a webapp?

why user can't access our S3 bucket even after I granted in the bucket policy?

How can I get the current Facebook user's public ID (not the scoped-id) or get the current user's profile photo

How can I let the superadmin user and user itself to access a API?

How can you set a user property so that I can track analytics using firebase

How can I get the user's username?