File tree 1 file changed +11
-11
lines changed
1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -123,31 +123,31 @@ service cloud.firestore {
123
123
function signedIn() {
124
124
return request.auth != null;
125
125
}
126
-
126
+
127
127
function isAdmin() {
128
- return signedIn() &&
128
+ return signedIn() &&
129
129
'ADMIN'in get(/databases/$(database)/documents/users/$(request.auth.uid)).data.roles.values();
130
130
}
131
-
132
- function ownsMessage () {
131
+
132
+ function isOwner () {
133
133
return signedIn() && request.auth.uid == resource.data.userId;
134
134
}
135
-
135
+
136
136
function isSelf() {
137
137
return signedIn() && request.auth.uid == resource.id;
138
138
}
139
-
139
+
140
140
// Rules
141
141
match /users/{userId} {
142
- allow get: if isSelf();
143
142
allow list: if isAdmin();
144
- allow write: if isSelf() || isAdmin();
143
+ allow get, update, delete: if isSelf() || isAdmin();
144
+ allow create: if signedIn();
145
145
}
146
-
146
+
147
147
match /messages/{messageId} {
148
148
allow read: if signedIn();
149
- allow create: if signedIn();
150
- allow update, delete: if signedIn() && ownsMessage ();
149
+ allow create: if signedIn() && request.resource.data.userId == request.auth.uid
150
+ allow update, delete: if signedIn() && isOwner ();
151
151
}
152
152
}
153
153
}
You can’t perform that action at this time.
0 commit comments