Created
May 24, 2021 21:29
-
-
Save hscheuerle/fb58ce4728113139eb2540fd6430b5cf to your computer and use it in GitHub Desktop.
DocumentReference serialization is type path in Firestore rules, forward slash paths are type path in "raw" form. Here's a utility for checking ownership
This file contains hidden or 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
function sentInvitation(invitationId) { | |
return exists(/databases/$(database)/documents/accounts/$(request.auth.uid)) | |
&& get(/databases/$(database)/documents/invitations/$(invitationId)).data.invitedBy == /databases/$(database)/documents/accounts/$(request.auth.uid) | |
} | |
// In production, wrapping exists and get in small utilities is worth tradeoff in code readability | |
// chaining this with utility that null-checks auth and auth.uid helps read rule errors in unit tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment