@edgedev/firebase 1.7.5 → 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 +49 -1
- 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,6 +1562,27 @@ export const EdgeFirebase = class {
|
|
|
1535
1562
|
}
|
|
1536
1563
|
};
|
|
1537
1564
|
|
|
1565
|
+
public storeDocRaw = async (
|
|
1566
|
+
collectionPath: string,
|
|
1567
|
+
item: object,
|
|
1568
|
+
docId?: string,
|
|
1569
|
+
): Promise<actionResponse> => {
|
|
1570
|
+
const cloneItem = JSON.parse(JSON.stringify(item));
|
|
1571
|
+
if (docId !== undefined) {
|
|
1572
|
+
await setDoc( doc(this.db, collectionPath, docId), cloneItem);
|
|
1573
|
+
} else {
|
|
1574
|
+
await addDoc(
|
|
1575
|
+
collection(this.db, collectionPath),
|
|
1576
|
+
cloneItem
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1579
|
+
return this.sendResponse({
|
|
1580
|
+
success: true,
|
|
1581
|
+
message: "",
|
|
1582
|
+
meta: {}
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1538
1586
|
|
|
1539
1587
|
public storeDoc = async (
|
|
1540
1588
|
collectionPath: string,
|