From 47fe6486d5411f005a58777aa3cc61c402880032 Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Thu, 4 Aug 2022 10:52:16 +0200 Subject: [PATCH] Implement auto-account --- src/http/routes/hkrpg_global/mdk/shield/api/login.ts | 9 +++++++++ src/util/Config.ts | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/http/routes/hkrpg_global/mdk/shield/api/login.ts b/src/http/routes/hkrpg_global/mdk/shield/api/login.ts index 4a944ea..dac6c71 100644 --- a/src/http/routes/hkrpg_global/mdk/shield/api/login.ts +++ b/src/http/routes/hkrpg_global/mdk/shield/api/login.ts @@ -1,5 +1,6 @@ import { Request, Response } from "express"; import Account from "../../../../../../db/Account"; +import Config from "../../../../../../util/Config"; import Logger from "../../../../../../util/Logger"; const c = new Logger("Dispatch"); @@ -20,6 +21,14 @@ export default async function handle(req: Request, res: Response) { } } if (!acc) { + if (Config.AUTO_ACCOUNT) { + const account = await Account.create(req.body.account); + c.log(`Account ${account.name} with UID ${account.uid} auto-created.`); + dataObj.data.account = account; + res.send(dataObj); + return; + } + dataObj.retcode = -202; dataObj.message = "Account not found"; c.warn(`Player ${req.body.account} not found (${req.ip})`); diff --git a/src/util/Config.ts b/src/util/Config.ts index 2eb2548..2a68987 100644 --- a/src/util/Config.ts +++ b/src/util/Config.ts @@ -27,7 +27,8 @@ const DEFAULT_CONFIG = { SERVER_PORT: 22102, MAINTENANCE: false, MAINTENANCE_MSG: "Server is in maintenance mode." - } + }, + AUTO_ACCOUNT: false } type DefaultConfig = typeof DEFAULT_CONFIG; @@ -80,6 +81,7 @@ export default class Config { MAINTENANCE: boolean; MAINTENANCE_MSG: string; } = Config.config.GAMESERVER; + public static AUTO_ACCOUNT: boolean = Config.config.AUTO_ACCOUNT; private constructor() { } }