Merge remote-tracking branch 'origin/develop' into feature/level-file-upload
This commit is contained in:
@@ -126,7 +126,7 @@ async function post(req: NextApiRequest, res: NextApiResponse) {
|
||||
const corporateSnapshot = await getDocs(corporateQ);
|
||||
|
||||
if (!corporateSnapshot.empty) {
|
||||
const corporateUser = corporateSnapshot.docs[0].data() as CorporateUser;
|
||||
const corporateUser = {...corporateSnapshot.docs[0].data(), id: corporateSnapshot.docs[0].id} as CorporateUser;
|
||||
await setDoc(doc(db, "codes", code), {creator: corporateUser.id}, {merge: true});
|
||||
|
||||
const q = query(
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user