let the users wait
This commit is contained in:
@@ -45,8 +45,6 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
const targetUser = {...docTargetUser.data(), id: docTargetUser.id} as User;
|
const targetUser = {...docTargetUser.data(), id: docTargetUser.id} as User;
|
||||||
|
|
||||||
if (user.type === "corporate" && (targetUser.type === "student" || targetUser.type === "teacher")) {
|
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)));
|
const userParticipantGroup = await getDocs(query(collection(db, "groups"), where("participants", "array-contains", id)));
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
...userParticipantGroup.docs
|
...userParticipantGroup.docs
|
||||||
@@ -66,14 +64,6 @@ async function del(req: NextApiRequest, res: NextApiResponse) {
|
|||||||
return;
|
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 auth.deleteUser(id);
|
||||||
await deleteDoc(doc(db, "users", id));
|
await deleteDoc(doc(db, "users", id));
|
||||||
const userCodeDocs = await getDocs(query(collection(db, "codes"), where("userId", "==", 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) {
|
async function get(req: NextApiRequest, res: NextApiResponse) {
|
||||||
|
|||||||
Reference in New Issue
Block a user