Files
prayer-app/firestore.rules
T

44 lines
1.6 KiB
Plaintext

rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Allow authenticated users to read/write their own data
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Allow authenticated users to read/write their own prayers
match /prayers/{prayerId} {
allow read, write: if request.auth != null &&
resource.data.userId == request.auth.uid;
allow create: if request.auth != null &&
request.resource.data.userId == request.auth.uid;
}
// Allow server-side API access for scheduled emails (no auth required for GET)
match /prayers {
allow read: if true;
}
// Allow server-side API access for scheduled emails
match /users {
allow read: if true;
}
// Allow authenticated users to read/write config (for admin settings)
match /config/{configId} {
allow read, write: if request.auth != null;
}
// Allow authenticated users to read/write shared prayers
match /sharedPrayers/{prayerId} {
allow read: if true; // Anyone can read shared prayers
allow create: if request.auth != null; // Only authenticated users can share
allow update: if request.auth != null &&
request.auth.uid == resource.data.userId; // Only the original sharer can update
allow delete: if request.auth != null &&
exists(/databases/$(database)/documents/config/admin) &&
request.auth.token.email in
get(/databases/$(database)/documents/config/admin).data.adminEmails; // Only admins can delete
}
}
}