From 932add15be6885645558040cee90d0d082cf55eb Mon Sep 17 00:00:00 2001 From: AlexisinGit <136088944+AlexisinGit@users.noreply.github.com> Date: Tue, 23 Sep 2025 04:45:37 +0800 Subject: [PATCH] setAccountCheatController type check (2) --- src/controllers/custom/setAccountCheatController.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/custom/setAccountCheatController.ts b/src/controllers/custom/setAccountCheatController.ts index 4ad41d17..3fbc398d 100644 --- a/src/controllers/custom/setAccountCheatController.ts +++ b/src/controllers/custom/setAccountCheatController.ts @@ -3,11 +3,18 @@ import { getAccountIdForRequest } from "../../services/loginService.ts"; import { sendWsBroadcastTo } from "../../services/wsService.ts"; import type { IAccountCheats } from "../../types/inventoryTypes/inventoryTypes.ts"; import type { RequestHandler } from "express"; +import { logger } from "../../utils/logger.ts"; export const setAccountCheatController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); const payload = req.body as ISetAccountCheatRequest; const inventory = await getInventory(accountId, payload.key); + + if (payload.value == undefined) { + logger.warn(`[setAccountCheatController] set ${payload.key} to ${payload.value}`); + return + } + inventory[payload.key] = payload.value as never; await inventory.save(); res.end(); @@ -18,5 +25,5 @@ export const setAccountCheatController: RequestHandler = async (req, res) => { interface ISetAccountCheatRequest { key: keyof IAccountCheats; - value: boolean | number; + value: IAccountCheats[keyof IAccountCheats]; }