@edgedev/firebase 1.7.6 → 1.7.8
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/README.md +2 -2
- package/edgeFirebase.ts +28 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -791,7 +791,7 @@ service cloud.firestore {
|
|
|
791
791
|
allow read: if readSelf();
|
|
792
792
|
allow create: if false;
|
|
793
793
|
allow update: if false;
|
|
794
|
-
allow delete: if
|
|
794
|
+
allow delete: if readSelf();
|
|
795
795
|
}
|
|
796
796
|
|
|
797
797
|
match /databases/{database}/documents/collection-data/{collectionPath} {
|
|
@@ -966,7 +966,7 @@ service cloud.firestore {
|
|
|
966
966
|
allow list: if canList();
|
|
967
967
|
allow create: if canCreate();
|
|
968
968
|
allow update: if canUpdate();
|
|
969
|
-
|
|
969
|
+
allow delete: if request.auth.uid == resource.data.userId // TODO: if isTemplate is true... can delete... if assign permission
|
|
970
970
|
}
|
|
971
971
|
|
|
972
972
|
match /databases/{database}/documents/{seg1} {
|
package/edgeFirebase.ts
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
sendPasswordResetEmail,
|
|
43
43
|
confirmPasswordReset,
|
|
44
44
|
connectAuthEmulator,
|
|
45
|
+
deleteUser,
|
|
45
46
|
} from "firebase/auth";
|
|
46
47
|
|
|
47
48
|
|
|
@@ -576,7 +577,33 @@ export const EdgeFirebase = class {
|
|
|
576
577
|
});
|
|
577
578
|
}
|
|
578
579
|
};
|
|
579
|
-
|
|
580
|
+
|
|
581
|
+
//TODO: Document this function
|
|
582
|
+
public deleteSelf = async (): Promise<actionResponse> => {
|
|
583
|
+
const userId = this.user.uid;
|
|
584
|
+
const userRef = doc(this.db, "users", userId);
|
|
585
|
+
const userSnap = await getDoc(userRef);
|
|
586
|
+
if (userSnap.exists()) {
|
|
587
|
+
const userStagingRef = doc(this.db, "staged-users", userSnap.data().stagedDocId)
|
|
588
|
+
await deleteDoc(userStagingRef);
|
|
589
|
+
await deleteDoc(userRef);
|
|
590
|
+
const user = this.auth.currentUser;
|
|
591
|
+
await deleteUser(user);
|
|
592
|
+
this.logOut();
|
|
593
|
+
return this.sendResponse({
|
|
594
|
+
success: true,
|
|
595
|
+
message: "",
|
|
596
|
+
meta: {}
|
|
597
|
+
});
|
|
598
|
+
} else {
|
|
599
|
+
return this.sendResponse({
|
|
600
|
+
success: false,
|
|
601
|
+
message: "User does not exist",
|
|
602
|
+
meta: {}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
|
|
580
607
|
public addUser = async (newUser: newUser): Promise<actionResponse> => {
|
|
581
608
|
const canAssignRole = this.multiPermissionCheck(
|
|
582
609
|
"assign",
|
|
@@ -1535,7 +1562,6 @@ export const EdgeFirebase = class {
|
|
|
1535
1562
|
}
|
|
1536
1563
|
};
|
|
1537
1564
|
|
|
1538
|
-
//TODO: Add documentation for this function
|
|
1539
1565
|
public storeDocRaw = async (
|
|
1540
1566
|
collectionPath: string,
|
|
1541
1567
|
item: object,
|