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) {