Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions storage/storage.rules
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,19 @@ service firebase.storage {
allow read: if isSignedIn();
}

match /user-media/surveys/{surveyId}/{allPaths=**} {
/**
* Returns true iff the requesting user owns the media at the given path.
*/
function isResourceOwner(userId) {
return request.auth.uid == userId;
}

match /user-media/surveys/{surveyId}/users/{userId}/{allPaths=**} {
// Only users with permission to access the survey can read media.
allow read: if canViewSurvey(surveyId);

// Only users with permission to contribute data to the survey can create/update media.
allow create, write: if canCollectData(surveyId);
// Only the owning user with permission to contribute data to the survey can create/update media.
allow create, write: if isResourceOwner(userId) && canCollectData(surveyId);
}
}
}
Loading