@edgedev/firebase 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/edgeFirebase.ts +24 -0
- package/package.json +1 -1
- package/src/edgeFirebase.js +6 -0
- package/src/firestore.rules +11 -2
package/edgeFirebase.ts
CHANGED
|
@@ -1668,6 +1668,30 @@ export const EdgeFirebase = class {
|
|
|
1668
1668
|
this.state.users = items;
|
|
1669
1669
|
});
|
|
1670
1670
|
this.unsubscibe["staged-users"] = unsubscibe;
|
|
1671
|
+
} else {
|
|
1672
|
+
const q = query(
|
|
1673
|
+
collection(this.db, "public-users"),
|
|
1674
|
+
where(
|
|
1675
|
+
"collectionPaths",
|
|
1676
|
+
"array-contains",
|
|
1677
|
+
collectionPath.replaceAll('/', '-')
|
|
1678
|
+
)
|
|
1679
|
+
)
|
|
1680
|
+
const unsubscibe = await onSnapshot(q, (querySnapshot) => {
|
|
1681
|
+
const items = {};
|
|
1682
|
+
querySnapshot.forEach((doc) => {
|
|
1683
|
+
const user = doc.data();
|
|
1684
|
+
const docId = doc.id;
|
|
1685
|
+
const item = {
|
|
1686
|
+
docId,
|
|
1687
|
+
meta: user.meta,
|
|
1688
|
+
userId: user.userId,
|
|
1689
|
+
}
|
|
1690
|
+
items[doc.id] = item;
|
|
1691
|
+
});
|
|
1692
|
+
this.state.users = items;
|
|
1693
|
+
});
|
|
1694
|
+
this.unsubscibe["staged-users"] = unsubscibe;
|
|
1671
1695
|
}
|
|
1672
1696
|
}
|
|
1673
1697
|
};
|
package/package.json
CHANGED
package/src/edgeFirebase.js
CHANGED
|
@@ -277,6 +277,12 @@ function setUser(userRef, newData, oldData, stagedDocId) {
|
|
|
277
277
|
return userRef.get().then((user) => {
|
|
278
278
|
let userUpdate = { meta: newData.meta, stagedDocId }
|
|
279
279
|
|
|
280
|
+
if (newData.meta && newData.meta.name) {
|
|
281
|
+
const publicUserRef = db.collection('public-users').doc(newData.userId)
|
|
282
|
+
const publicMeta = { name: newData.meta.name }
|
|
283
|
+
publicUserRef.set({ uid: newData.uid, meta: publicMeta, collectionPaths: newData.collectionPaths, userId: newData.userId })
|
|
284
|
+
}
|
|
285
|
+
|
|
280
286
|
if (Object.prototype.hasOwnProperty.call(newData, 'roles')) {
|
|
281
287
|
userUpdate = { ...userUpdate, roles: newData.roles }
|
|
282
288
|
}
|
package/src/firestore.rules
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
rules_version = '2';
|
|
1
2
|
// #EDGE FIREBASE RULES START
|
|
2
3
|
service cloud.firestore {
|
|
3
4
|
|
|
@@ -8,6 +9,14 @@ service cloud.firestore {
|
|
|
8
9
|
allow delete: if false;
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
match /databases/{database}/documents/public-users/{user} {
|
|
13
|
+
allow read: if true;
|
|
14
|
+
allow list: if true;
|
|
15
|
+
allow create: if false;
|
|
16
|
+
allow update: if false;
|
|
17
|
+
allow delete: if false;
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
match /databases/{database}/documents/events/{event} {
|
|
12
21
|
allow read: if false;
|
|
13
22
|
allow create: if false;
|
|
@@ -228,7 +237,7 @@ service cloud.firestore {
|
|
|
228
237
|
}
|
|
229
238
|
function checkPermission(collectionPath, permissionCheck) {
|
|
230
239
|
let user = get(/databases/$(database)/documents/users/$(request.auth.uid)).data;
|
|
231
|
-
let skipPaths = ["collection-data", "users", "staged-users", "events", "rule-helpers"];
|
|
240
|
+
let skipPaths = ["collection-data", "users", "staged-users", "events", "rule-helpers", "phone-auth", "public-users"];
|
|
232
241
|
let ruleHelper = get(/databases/$(database)/documents/rule-helpers/$(request.auth.uid)).data;
|
|
233
242
|
return !(collectionPath in skipPaths) &&
|
|
234
243
|
!(permissionCheck == "write" &&
|
|
@@ -303,4 +312,4 @@ service cloud.firestore {
|
|
|
303
312
|
}
|
|
304
313
|
}
|
|
305
314
|
}
|
|
306
|
-
|
|
315
|
+
// #EDGE FIREBASE RULES END
|