@edgedev/firebase 2.1.38 → 2.1.40
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 +28 -4
- package/package.json +1 -1
- package/src/firestore.rules +8 -0
package/edgeFirebase.ts
CHANGED
|
@@ -195,6 +195,16 @@ interface permissionStatus {
|
|
|
195
195
|
badCollectionPaths: string[];
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
interface User {
|
|
199
|
+
userId: string;
|
|
200
|
+
stagedDocId: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface Meta {
|
|
204
|
+
[key: string]: unknown;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
|
|
198
208
|
export const EdgeFirebase = class {
|
|
199
209
|
constructor(
|
|
200
210
|
firebaseConfig: firebaseConfig = {
|
|
@@ -800,11 +810,25 @@ export const EdgeFirebase = class {
|
|
|
800
810
|
}
|
|
801
811
|
};
|
|
802
812
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
public setUserMeta = async (meta: Meta, userId = ''): Promise<actionResponse> => {
|
|
816
|
+
let stagedDocId = this.user.stagedDocId;
|
|
817
|
+
if (userId) {
|
|
818
|
+
const users = Object.values(this.state.users) as User[];
|
|
819
|
+
const user = users.find((u) => u.userId === userId);
|
|
820
|
+
if (user) {
|
|
821
|
+
stagedDocId = user.stagedDocId;
|
|
822
|
+
} else {
|
|
823
|
+
return this.sendResponse({
|
|
824
|
+
success: false,
|
|
825
|
+
message: "You don't have access to change this user.",
|
|
826
|
+
meta: {}
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
}
|
|
806
830
|
for (const [key, value] of Object.entries(meta)) {
|
|
807
|
-
await updateDoc(doc(this.db, "staged-users/" +
|
|
831
|
+
await updateDoc(doc(this.db, "staged-users/" + stagedDocId), {
|
|
808
832
|
["meta." + key]: value, uid: this.user.uid
|
|
809
833
|
});
|
|
810
834
|
}
|
package/package.json
CHANGED
package/src/firestore.rules
CHANGED
|
@@ -31,6 +31,14 @@ service cloud.firestore {
|
|
|
31
31
|
allow update: if false;
|
|
32
32
|
allow delete: if false;
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
match /databases/{database}/documents/system/{event} {
|
|
37
|
+
allow read: if false;
|
|
38
|
+
allow create: if false;
|
|
39
|
+
allow update: if false;
|
|
40
|
+
allow delete: if false;
|
|
41
|
+
}
|
|
34
42
|
|
|
35
43
|
match /databases/{database}/documents/rule-helpers/{helper} {
|
|
36
44
|
allow read: if false;
|