From 8a78ccd68a14e2b17deccae199c590c8a47f8a7f Mon Sep 17 00:00:00 2001 From: AlexisinGit <136088944+AlexisinGit@users.noreply.github.com> Date: Sun, 31 Aug 2025 14:45:32 +0800 Subject: [PATCH 1/4] setAccountCheatController type check --- src/controllers/custom/setAccountCheatController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/custom/setAccountCheatController.ts b/src/controllers/custom/setAccountCheatController.ts index 07a1da4f..4ad41d17 100644 --- a/src/controllers/custom/setAccountCheatController.ts +++ b/src/controllers/custom/setAccountCheatController.ts @@ -8,7 +8,7 @@ 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; + inventory[payload.key] = payload.value as never; await inventory.save(); res.end(); if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) { @@ -18,5 +18,5 @@ export const setAccountCheatController: RequestHandler = async (req, res) => { interface ISetAccountCheatRequest { key: keyof IAccountCheats; - value: boolean; + value: boolean | number; } -- 2.47.2 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 2/4] 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]; } -- 2.47.2 From e3cd4f4c4a937a1e2a4cf382edba1863e3874a2e Mon Sep 17 00:00:00 2001 From: AlexisinGit <136088944+AlexisinGit@users.noreply.github.com> Date: Tue, 23 Sep 2025 05:04:28 +0800 Subject: [PATCH 3/4] webui-account-cheats-payload-input-by-value --- static/webui/script.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index bf971cf8..40b68999 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -1986,7 +1986,11 @@ function updateInventory() { } for (const elm of accountCheats) { - elm.checked = !!data[elm.id]; + if (elm.type === "checkbox") { + elm.checked = !!data[elm.id]; + } else if (elm.type === "number") { + elm.value = data[elm.id] !== undefined ? data[elm.id] : elm.getAttribute("data-default") || ""; + } } }); }); @@ -3214,9 +3218,10 @@ function doIntrinsicsUnlockAll() { }); } -document.querySelectorAll("#account-cheats input[type=checkbox]").forEach(elm => { +document.querySelectorAll("#account-cheats input[type=checkbox], #account-cheats input[type=number]").forEach(elm => { elm.onchange = function () { revalidateAuthz().then(() => { + const value = elm.type === "checkbox" ? elm.checked : elm.value; $.post({ url: "/custom/setAccountCheat?" + window.authz, contentType: "application/json", @@ -3237,7 +3242,7 @@ document.querySelectorAll("#guild-cheats input[type=checkbox]").forEach(elm => { contentType: "application/json", data: JSON.stringify({ key: elm.id, - value: elm.checked + value: value }) }); }); -- 2.47.2 From 26fcc7efa1ef9c498d40ea48f98aa8f2b5fccb59 Mon Sep 17 00:00:00 2001 From: AlexisinGit <136088944+AlexisinGit@users.noreply.github.com> Date: Tue, 23 Sep 2025 05:39:43 +0800 Subject: [PATCH 4/4] verify & fix --- src/controllers/custom/setAccountCheatController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/custom/setAccountCheatController.ts b/src/controllers/custom/setAccountCheatController.ts index 3fbc398d..19661c1e 100644 --- a/src/controllers/custom/setAccountCheatController.ts +++ b/src/controllers/custom/setAccountCheatController.ts @@ -12,9 +12,9 @@ export const setAccountCheatController: RequestHandler = async (req, res) => { if (payload.value == undefined) { logger.warn(`[setAccountCheatController] set ${payload.key} to ${payload.value}`); - return + return; } - + inventory[payload.key] = payload.value as never; await inventory.save(); res.end(); -- 2.47.2