-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstorage.rules
More file actions
30 lines (25 loc) · 1.04 KB
/
storage.rules
File metadata and controls
30 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
rules_version = '2';
// Firebase Storage Security Rules
service firebase.storage {
match /b/{bucket}/o {
// Signal photos - hierarchical structure
match /signals/{signalId}/photos/{fileName} {
// Anyone can read signal photos
allow read: if true;
// Only the signal reporter can upload or delete photos
allow write, delete: if request.auth != null &&
isSignalReporter(signalId, request.auth.uid);
}
// Future: Comment photos (when implemented)
match /signals/{signalId}/comments/{commentId}/photos/{fileName} {
allow read: if true;
// TODO: Add write rules for comment authors when feature is implemented
}
// Helper function to check if the user is the signal reporter
function isSignalReporter(signalId, userId) {
let signal = firestore.get(/databases/(default)/documents/signals/$(signalId)).data;
// Compare the reporter DocumentReference path with the current user's path
return signal.reporter == /databases/(default)/documents/users/$(userId);
}
}
}