@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.
Files changed (2) hide show
  1. package/edgeFirebase.ts +29 -4
  2. 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
- public setUserMeta = async (meta: unknown): Promise<actionResponse> => {
804
- //TODO: Change setUserMeta to also be used by someone with assign permissions and
805
- // add a permissionCheck here for it.
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/" + this.user.stagedDocId), {
832
+ await updateDoc(doc(this.db, "staged-users/" + stagedDocId), {
808
833
  ["meta." + key]: value, uid: this.user.uid
809
834
  });
810
835
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "2.1.39",
3
+ "version": "2.1.41",
4
4
  "description": "Vue 3 / Nuxt 3 Plugin or Nuxt 3 plugin for firebase authentication and firestore.",
5
5
  "main": "index.ts",
6
6
  "scripts": {