added admin page
This commit is contained in:
@@ -3,6 +3,21 @@ rules_version = '2';
|
||||
service cloud.firestore {
|
||||
match /databases/{database}/documents {
|
||||
|
||||
// Helper: check if the authenticated user is an admin
|
||||
function isAdmin() {
|
||||
return request.auth != null
|
||||
&& request.auth.token.email in get(/databases/$(database)/documents/config/admins).data.emails;
|
||||
}
|
||||
|
||||
// Config collection (admin allowlist etc.)
|
||||
match /config/{docId} {
|
||||
allow read: if request.auth != null;
|
||||
// Allow initial creation (bootstrap) by authenticated user; updates only by admins
|
||||
allow create: if request.auth != null;
|
||||
allow update: if isAdmin();
|
||||
allow delete: if false;
|
||||
}
|
||||
|
||||
// Students collection (read-only, managed via admin/console)
|
||||
match /students/{studentId} {
|
||||
allow read: if true;
|
||||
@@ -13,10 +28,9 @@ service cloud.firestore {
|
||||
match /donors/{donorId} {
|
||||
// Anyone can read donors
|
||||
allow read: if true;
|
||||
// Only authenticated users can create donors
|
||||
// Authenticated users can create donors; admins can also update/delete
|
||||
allow create: if request.auth != null;
|
||||
// No one can update or delete donors (admin-only via console)
|
||||
allow update, delete: if false;
|
||||
allow update, delete: if isAdmin();
|
||||
}
|
||||
|
||||
// Comments collection
|
||||
|
||||
Reference in New Issue
Block a user