-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirestore.rules
More file actions
28 lines (23 loc) · 863 Bytes
/
Copy pathfirestore.rules
File metadata and controls
28 lines (23 loc) · 863 Bytes
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
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Helper functions
function isSignedIn() {
return request.auth != null;
}
function isOwner(userId) {
return request.auth.uid == userId;
}
// Users collection
match /users/{userId} {
// Anyone can read a user's profile if it's public
allow get: if resource.data.publicProfile == true || isOwner(userId);
// Logged-in users can list public profiles
allow list: if isSignedIn() && query.filters.size() == 1 && query.filters[0][0] == 'publicProfile' && query.filters[0][2] == true;
// Only the user themselves can create or update their own profile
allow create, update: if isOwner(userId);
// Users cannot delete their profiles through the client
allow delete: if false;
}
}
}