Walfy Doc
Installation PlansSupport
  • Introduction
  • Changelogs
  • Getting Started
  • 🚀Admin Setup
    • 1. Flutter Installation
    • 2. Code Setup
    • 3. Firebase Setup
      • 3.1 Firestore Database Setup
      • 3.2 Database Security Rules
      • 3.3 Database Index Setup
      • 3.4 Firebase Storage Setup
    • 4. Code Configs
    • 5. Upload to Firebase Hosting
    • 6. Conclusion
  • 📱App Setup
    • 1. Introduction
    • 2. Code Setup
    • 3. Firebase Setup for Android
      • 3.1 Android Package Name Setup on Firebase
      • 3.2 Change Package Name Android
      • 3.3 Generate Debug Certificate
      • 3.4 Generate Release Certificate
      • 3.5 Google Sign In Setup for Android
      • 3.6 Additional Firebase Setup for Android
    • 4. Push Notification Setup
    • 5. Ads Setup
      • 5.1 Admob Setup for Android
    • 6. App Information Setup
    • 7. Change App Name for Android
    • 8. Change App Icon
    • 9. Change Splash Icon
    • 10. Run The App
    • 11. Admin Setup
    • 12. Releasing the Android App
  • ✨Updates
    • Migrate to v3.1.0
Powered by GitBook
On this page
  1. Admin Setup
  2. 3. Firebase Setup

3.2 Database Security Rules

  • From the Firestore Database, Click on the Rules tab and copy and paste the following code below:

Firestore Security Rules
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
  
  	match /users/{userId} {
    	allow read: if true;
      allow write: if isUserSignedIn() && request.auth.uid == userId;
    }
    
    match /contents/{id} {
    	allow read : if true;
      allow create: if isUserSignedIn() && isAdmin();
      allow update: if isUserSignedIn() || isAdmin();
      allow delete : if isUserSignedIn() && isAdmin();
    }
    
    match /categories/{document=**} {
    	allow read : if true;
      allow write: if isUserSignedIn() && isAdmin();
    }
    
    match /item_count/{document=**} {
    	allow read: if true;
      allow create, update: if isUserSignedIn() || isAdmin();
    }
  
  	function isUserSignedIn (){
    	return request.auth != null;
    }
    
    function isAdmin (){
    	return "admin" in get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role;
    }
    
  }
}
  • Click on Publish button to publish the security rules. That's it.

Previous3.1 Firestore Database SetupNext3.3 Database Index Setup

Last updated 2 years ago

🚀