Last active
November 15, 2024 19:21
-
-
Save bradtraversy/6d7de7e877d169a6aa4e61140d25767f to your computer and use it in GitHub Desktop.
Firebase rules for house marketplace app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FIRESTORE RULES | |
rules_version = '2'; | |
service cloud.firestore { | |
match /databases/{database}/documents { | |
// Listings | |
match /listings/{listing} { | |
allow read; | |
allow create: if request.auth != null && request.resource.data.imgUrls.size() < 7; | |
allow delete: if resource.data.userRef == request.auth.uid; | |
allow update: if resource.data.userRef == request.auth.uid; | |
} | |
// Users | |
match /users/{user} { | |
allow read; | |
allow create; | |
allow update: if request.auth.uid == user | |
} | |
} | |
} | |
// STORAGE RULES | |
rules_version = '2'; | |
service firebase.storage { | |
match /b/{bucket}/o { | |
match /{allPaths=**} { | |
allow read; | |
allow write: if | |
request.auth != null && | |
request.resource.size < 2 * 1024 * 1024 && //2MB | |
request.resource.contentType.matches('image/.*') | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
so i'm getting toast error and also logs in my account.......how do i fix this ? @bradtraversy