Challenge - 5 Problems
Firebase Resource Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
What is the output of this Firebase Firestore security rule evaluation?
Given the following Firestore security rule snippet, what will be the result of a read request if the document's field
ownerId matches the request.auth.uid?Firebase
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read: if resource.data.ownerId == request.auth.uid;
}
}
}Attempts:
2 left
💡 Hint
Remember that
resource.data refers to the existing document data and request.auth.uid is the authenticated user's ID.✗ Incorrect
The rule allows read access only if the document's ownerId field matches the authenticated user's ID. This ensures users can only read their own documents.
🧠 Conceptual
intermediate1:30remaining
Which Firebase request object property contains the data sent by the client in a write operation?
In Firebase security rules, when a client tries to write data, which property of the
request object holds the new data the client wants to write?Attempts:
2 left
💡 Hint
Think about the difference between
resource and request.resource.✗ Incorrect
request.resource.data contains the data the client wants to write. resource.data is the existing data before the write.
❓ Architecture
advanced2:30remaining
Which Firebase security rule correctly restricts document deletion to the document owner only?
You want to allow only the owner of a document to delete it. The document has a field
ownerId. Which rule correctly enforces this?Attempts:
2 left
💡 Hint
Remember that
resource.data is the current document data before deletion.✗ Incorrect
For deletion, resource.data holds the existing document data. The rule checks if the authenticated user is the owner.
❓ security
advanced2:00remaining
What error occurs if you try to access
resource.data in a create request where the document does not exist yet?In a Firestore security rule for a create operation, what happens if you try to read
resource.data?Attempts:
2 left
💡 Hint
Think about the difference between existing data and new data during create.
✗ Incorrect
On create, resource.data is null because the document does not exist yet. Accessing it returns null, not an error.
✅ Best Practice
expert3:00remaining
Which Firebase security rule snippet best prevents unauthorized updates to a user's email field?
You want to allow users to update their documents but prevent them from changing the
email field. Which rule snippet enforces this correctly?Attempts:
2 left
💡 Hint
Compare the new email field with the existing one to detect changes.
✗ Incorrect
Option B ensures the email field is unchanged during update, preventing unauthorized modifications.