@edgedev/firebase 2.1.39 → 2.1.41
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 +29 -4
- package/package.json +1 -1
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
|
+
docId: 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,26 @@ 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
|
+
console.log(user)
|
|
822
|
+
stagedDocId = user.docId;
|
|
823
|
+
} else {
|
|
824
|
+
return this.sendResponse({
|
|
825
|
+
success: false,
|
|
826
|
+
message: "You don't have access to change this user.",
|
|
827
|
+
meta: {}
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
}
|
|
806
831
|
for (const [key, value] of Object.entries(meta)) {
|
|
807
|
-
await updateDoc(doc(this.db, "staged-users/" +
|
|
832
|
+
await updateDoc(doc(this.db, "staged-users/" + stagedDocId), {
|
|
808
833
|
["meta." + key]: value, uid: this.user.uid
|
|
809
834
|
});
|
|
810
835
|
}
|