@edgedev/firebase 1.7.6 → 1.7.7
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 -2
- package/package.json +1 -1
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,
|