@edgedev/firebase 2.1.64 → 2.1.66
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 +16 -3
- package/package.json +1 -1
package/edgeFirebase.ts
CHANGED
|
@@ -853,13 +853,11 @@ export const EdgeFirebase = class {
|
|
|
853
853
|
|
|
854
854
|
|
|
855
855
|
|
|
856
|
-
public setUserMeta = async (meta: Meta, userId = ''): Promise<actionResponse> => {
|
|
857
|
-
let stagedDocId = this.user.stagedDocId;
|
|
856
|
+
public setUserMeta = async (meta: Meta, userId = '', stagedDocId = ''): Promise<actionResponse> => {
|
|
858
857
|
if (userId) {
|
|
859
858
|
const users = Object.values(this.state.users) as User[];
|
|
860
859
|
const user = users.find((u) => u.userId === userId);
|
|
861
860
|
if (user) {
|
|
862
|
-
console.log(user)
|
|
863
861
|
stagedDocId = user.docId;
|
|
864
862
|
} else {
|
|
865
863
|
return this.sendResponse({
|
|
@@ -869,6 +867,20 @@ export const EdgeFirebase = class {
|
|
|
869
867
|
});
|
|
870
868
|
}
|
|
871
869
|
}
|
|
870
|
+
if (!userId && stagedDocId) {
|
|
871
|
+
const users = Object.values(this.state.users) as User[];
|
|
872
|
+
const user = users.find((u) => u.docId === stagedDocId);
|
|
873
|
+
if (!user) {
|
|
874
|
+
return this.sendResponse({
|
|
875
|
+
success: false,
|
|
876
|
+
message: "You don't have access to change this user.",
|
|
877
|
+
meta: {}
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
if (!stagedDocId) {
|
|
882
|
+
stagedDocId = this.user.stagedDocId;
|
|
883
|
+
}
|
|
872
884
|
for (const [key, value] of Object.entries(meta)) {
|
|
873
885
|
await updateDoc(doc(this.db, "staged-users/" + stagedDocId), {
|
|
874
886
|
["meta." + key]: value, uid: this.user.uid
|
|
@@ -1735,6 +1747,7 @@ export const EdgeFirebase = class {
|
|
|
1735
1747
|
docId,
|
|
1736
1748
|
meta: user.meta,
|
|
1737
1749
|
userId: user.userId,
|
|
1750
|
+
uid: user.uid,
|
|
1738
1751
|
}
|
|
1739
1752
|
items[doc.id] = item;
|
|
1740
1753
|
});
|