Complete the code to define a custom function named isOwner.
function [1](userId) { return request.auth.uid == userId; }
The function name must be isOwner to match the rule usage.
Complete the code to call the custom function isOwner inside the rule.
allow read: if [1](resource.data.ownerId);
The rule calls the custom function isOwner to check ownership.
Fix the error in the custom function to correctly check if the user is authenticated.
function isOwner(userId) {
return [1] != null && request.auth.uid == userId;
}Checking request.auth != null ensures the user is signed in before comparing user IDs.
Fill both blanks to define a custom function that checks if the user is an admin or the owner.
function [1](userId) { return request.auth != null && (request.auth.token.admin == true || request.auth.uid == [2]); }
The function isAdminOrOwner checks if the user is an admin or matches the userId parameter.
Fill the blanks to write a rule that allows write if the user is admin or owner using the custom function.
allow write: if [1](resource.data.[2]);
The rule calls isAdminOrOwner(resource.data.ownerId).