diff --git a/src/engine/db/handlers/dbAccountHandler.java b/src/engine/db/handlers/dbAccountHandler.java index ebf6048d..5829d9a2 100644 --- a/src/engine/db/handlers/dbAccountHandler.java +++ b/src/engine/db/handlers/dbAccountHandler.java @@ -121,6 +121,14 @@ public class dbAccountHandler extends dbHandlerBase { executeUpdate(); } + public void CREATE_SINGLE(String accountName, String password) { + + prepareCallable("CALL singleAccountCreate(?,?)"); + setString(1, accountName); + setString(2, password); + executeUpdate(); + } + public Account GET_ACCOUNT(String uname) { if (Account.AccountsMap.get(uname) != null) diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index d7f5041d..38e6c8f0 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -46,6 +46,7 @@ public enum ConfigManager { // Login server config MB_LOGIN_PORT, + MB_LOGIN_AUTOREG, MB_MAJOR_VER, MB_MINOR_VER, diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index 640baf8f..36f45917 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,26 @@ 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; + } + Logger.info("AutoRegister: " + uname + "/" + pass); + 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())