From 459d61b20a1f723fe93b183915f21798a70e6a74 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:19:33 -0400 Subject: [PATCH] Autoregister plugged in. --- .../server/login/LoginServerMsgHandler.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index 640baf8f..b9f11794 100644 --- a/src/engine/server/login/LoginServerMsgHandler.java +++ b/src/engine/server/login/LoginServerMsgHandler.java @@ -12,6 +12,7 @@ package engine.server.login; import engine.Enum; import engine.Enum.DispatchChannel; import engine.Enum.GameObjectType; +import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.SessionManager; import engine.job.JobScheduler; @@ -174,12 +175,25 @@ public class LoginServerMsgHandler implements NetMsgHandler { account = DbManager.AccountQueries.GET_ACCOUNT(uname); + // Create the account if it doesn't exist and MB_LOGIN_AUTOREG is TRUE; + // This is to support MagicBox users without a web hosting skillset. + if (account == null) { - this.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', clientConnection); - Logger.info("Could not find account (" + uname + ')'); - return; + if (ConfigManager.MB_LOGIN_AUTOREG.getValue().equals("FALSE")) { + this.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', clientConnection); + Logger.info("Could not find account (" + uname + ')'); + return; + } + DbManager.AccountQueries.CREATE_SINGLE(uname, pass); + account = DbManager.AccountQueries.GET_ACCOUNT(uname); + + if (account == null) { + this.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', clientConnection); + Logger.info("Could not auto-create (" + uname + ')'); + return; + } } if (account.getLastLoginFailure() + MBServerStatics.RESET_LOGIN_ATTEMPTS_AFTER < System.currentTimeMillis())