Compare commits
	
		
			5 Commits
		
	
	
		
			32c95b6715
			...
			0891608480
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					0891608480 | ||
| 
						 | 
					26fcc7efa1 | ||
| 
						 | 
					e3cd4f4c4a | ||
| 
						 | 
					932add15be | ||
| 
						 | 
					8a78ccd68a | 
@ -3,12 +3,19 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
 | 
				
			|||||||
import { sendWsBroadcastTo } from "../../services/wsService.ts";
 | 
					import { sendWsBroadcastTo } from "../../services/wsService.ts";
 | 
				
			||||||
import type { IAccountCheats } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
					import type { IAccountCheats } from "../../types/inventoryTypes/inventoryTypes.ts";
 | 
				
			||||||
import type { RequestHandler } from "express";
 | 
					import type { RequestHandler } from "express";
 | 
				
			||||||
 | 
					import { logger } from "../../utils/logger.ts";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const setAccountCheatController: RequestHandler = async (req, res) => {
 | 
					export const setAccountCheatController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
    const payload = req.body as ISetAccountCheatRequest;
 | 
					    const payload = req.body as ISetAccountCheatRequest;
 | 
				
			||||||
    const inventory = await getInventory(accountId, payload.key);
 | 
					    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();
 | 
					    await inventory.save();
 | 
				
			||||||
    res.end();
 | 
					    res.end();
 | 
				
			||||||
    if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) {
 | 
					    if (["infiniteCredits", "infinitePlatinum", "infiniteEndo", "infiniteRegalAya"].indexOf(payload.key) != -1) {
 | 
				
			||||||
@ -18,5 +25,5 @@ export const setAccountCheatController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
interface ISetAccountCheatRequest {
 | 
					interface ISetAccountCheatRequest {
 | 
				
			||||||
    key: keyof IAccountCheats;
 | 
					    key: keyof IAccountCheats;
 | 
				
			||||||
    value: boolean;
 | 
					    value: IAccountCheats[keyof IAccountCheats];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1986,7 +1986,11 @@ function updateInventory() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for (const elm of accountCheats) {
 | 
					            for (const elm of accountCheats) {
 | 
				
			||||||
 | 
					                if (elm.type === "checkbox") {
 | 
				
			||||||
                    elm.checked = !!data[elm.id];
 | 
					                    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 () {
 | 
					    elm.onchange = function () {
 | 
				
			||||||
        revalidateAuthz().then(() => {
 | 
					        revalidateAuthz().then(() => {
 | 
				
			||||||
 | 
					            const value = elm.type === "checkbox" ? elm.checked : elm.value;
 | 
				
			||||||
            $.post({
 | 
					            $.post({
 | 
				
			||||||
                url: "/custom/setAccountCheat?" + window.authz,
 | 
					                url: "/custom/setAccountCheat?" + window.authz,
 | 
				
			||||||
                contentType: "application/json",
 | 
					                contentType: "application/json",
 | 
				
			||||||
@ -3237,7 +3242,7 @@ document.querySelectorAll("#guild-cheats input[type=checkbox]").forEach(elm => {
 | 
				
			|||||||
                contentType: "application/json",
 | 
					                contentType: "application/json",
 | 
				
			||||||
                data: JSON.stringify({
 | 
					                data: JSON.stringify({
 | 
				
			||||||
                    key: elm.id,
 | 
					                    key: elm.id,
 | 
				
			||||||
                    value: elm.checked
 | 
					                    value: value
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user