Implement auto-account
This commit is contained in:
parent
1fb0f26796
commit
47fe6486d5
@ -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})`);
|
||||
|
@ -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() { }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user