From b7b2dca2dd801c6e97af4df669840ccfbeea9116 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Mon, 15 Jan 2024 11:02:40 +0000 Subject: [PATCH] Updated the user deletion to work in the backend --- src/pages/api/user.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/pages/api/user.ts b/src/pages/api/user.ts index 41474d5e..1e975ac4 100644 --- a/src/pages/api/user.ts +++ b/src/pages/api/user.ts @@ -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) {