My Firebase security rules are structured like this:
"users": {
"$uid": {
// Allows write access only to the user whose uid matches the key ($uid)
".write": "auth !== null && auth.uid === $uid",
// Grants read access to any user logged in with an email and password
".read": "auth !== null && auth.provider === 'password'"
}
},
Additionally, I have a unique userId
stored in the users/$uid
path. For example, my users/$uid
structure looks like this:
users
/$uid
/email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a9cfc6c6e9cbc8db87cac6c4">[email protected]</a>
/userId: "foobargayid123456"
I utilize this userId in other nodes, such as the profile_pictures
node, to establish dependencies:
profile_pictures
/userId
/thumbnail: "datablabla"
Inquiry
How can I adjust the firebase security rules for the profile_pictures
node so that only users with the id: users/$uid/userId
have permission to .write
to the profile_pictures/userId
node?