let the users wait

This commit is contained in:
Tiago Ribeiro
2024-09-02 21:31:26 +01:00
parent 640b6f0e4d
commit 0f38e01283

View File

@@ -45,8 +45,6 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
const targetUser = {...docTargetUser.data(), id: docTargetUser.id} as User;
if (user.type === "corporate" && (targetUser.type === "student" || targetUser.type === "teacher")) {
res.json({ok: true});
const userParticipantGroup = await getDocs(query(collection(db, "groups"), where("participants", "array-contains", id)));
await Promise.all([
...userParticipantGroup.docs
@@ -66,14 +64,6 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
return;
}
const permission = PERMISSIONS.deleteUser[targetUser.type];
if (!permission.list.includes(user.type)) {
res.status(403).json({ok: false});
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)));
@@ -96,6 +86,8 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
),
),
]);
res.json({ok: true});
}
async function get(req: NextApiRequest, res: NextApiResponse) {