Updated the user deletion to work in the backend

This commit is contained in:
Tiago Ribeiro
2024-01-15 11:02:40 +00:00
parent a14c9f8b3c
commit b7b2dca2dd

View File

@@ -49,6 +49,10 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
return;
}
res.json({ok: true});
await auth.deleteUser(id);
await deleteDoc(doc(db, "users", id));
const userCodeDocs = await getDocs(query(collection(db, "codes"), where("userId", "==", id)));
const userParticipantGroup = await getDocs(query(collection(db, "groups"), where("participants", "array-contains", id)));
const userGroupAdminDocs = await getDocs(query(collection(db, "groups"), where("admin", "==", id)));
@@ -62,11 +66,6 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
async (x) => await setDoc(x.ref, {participants: x.data().participants.filter((y: string) => y !== id)}, {merge: true}),
),
]);
await auth.deleteUser(id);
await deleteDoc(doc(db, "users", id));
res.json({ok: true});
}
async function get(req: NextApiRequest, res: NextApiResponse) {