diff --git a/src/controllers/custom/setAccountCheatController.ts b/src/controllers/custom/setAccountCheatController.ts index 07a1da4f..586cebb6 100644 --- a/src/controllers/custom/setAccountCheatController.ts +++ b/src/controllers/custom/setAccountCheatController.ts @@ -3,12 +3,19 @@ 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); - inventory[payload.key] = payload.value; + + if (payload.value == undefined) { + logger.warn(`Aborting setting ${payload.key} as undefined!`); + return; + } + + inventory[payload.key] = payload.value as never; await inventory.save(); res.end(); if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) { @@ -18,5 +25,5 @@ export const setAccountCheatController: RequestHandler = async (req, res) => { interface ISetAccountCheatRequest { key: keyof IAccountCheats; - value: boolean; + value: IAccountCheats[keyof IAccountCheats]; }