From 2997e5bda2f43e2c4d71a507443e43bfdd629281 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:05:05 -0400 Subject: [PATCH 1/6] Feature needs a new configuration entry. --- src/engine/gameManager/ConfigManager.java | 1 + 1 file changed, 1 insertion(+) 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, From 0beb75c9fb5459e203628b1a8764122a96acf368 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:11:35 -0400 Subject: [PATCH 2/6] Handler added to create single account --- src/engine/db/handlers/dbAccountHandler.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/engine/db/handlers/dbAccountHandler.java b/src/engine/db/handlers/dbAccountHandler.java index ebf6048d..c62b02f9 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) From 459d61b20a1f723fe93b183915f21798a70e6a74 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:19:33 -0400 Subject: [PATCH 3/6] 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()) From bf3517ebb37ea749028c90c220bcdd3b89238995 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:30:47 -0400 Subject: [PATCH 4/6] More logging --- src/engine/server/login/LoginServerMsgHandler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/server/login/LoginServerMsgHandler.java b/src/engine/server/login/LoginServerMsgHandler.java index b9f11794..36f45917 100644 --- a/src/engine/server/login/LoginServerMsgHandler.java +++ b/src/engine/server/login/LoginServerMsgHandler.java @@ -186,6 +186,7 @@ public class LoginServerMsgHandler implements NetMsgHandler { return; } + Logger.info("AutoRegister: " + uname + "/" + pass); DbManager.AccountQueries.CREATE_SINGLE(uname, pass); account = DbManager.AccountQueries.GET_ACCOUNT(uname); From 890f9ad49dc657d2f093127c0be0c5b9f70576f1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:38:57 -0400 Subject: [PATCH 5/6] SQL caretfix --- src/engine/db/handlers/dbAccountHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbAccountHandler.java b/src/engine/db/handlers/dbAccountHandler.java index c62b02f9..3b2aa5f5 100644 --- a/src/engine/db/handlers/dbAccountHandler.java +++ b/src/engine/db/handlers/dbAccountHandler.java @@ -123,7 +123,7 @@ public class dbAccountHandler extends dbHandlerBase { public void CREATE_SINGLE(String accountName, String password) { - prepareCallable("CALL singleAccountCreate(`?`,`?"); + prepareCallable("CALL singleAccountCreate(`?`,`?`);"); setString(1, accountName); setString(2, password); executeUpdate(); From 4205ebe384e938c72327f8b958fcf067c11210a4 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 30 Apr 2022 14:42:09 -0400 Subject: [PATCH 6/6] SQL caretfix --- src/engine/db/handlers/dbAccountHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/db/handlers/dbAccountHandler.java b/src/engine/db/handlers/dbAccountHandler.java index 3b2aa5f5..5829d9a2 100644 --- a/src/engine/db/handlers/dbAccountHandler.java +++ b/src/engine/db/handlers/dbAccountHandler.java @@ -123,7 +123,7 @@ public class dbAccountHandler extends dbHandlerBase { public void CREATE_SINGLE(String accountName, String password) { - prepareCallable("CALL singleAccountCreate(`?`,`?`);"); + prepareCallable("CALL singleAccountCreate(?,?)"); setString(1, accountName); setString(2, password); executeUpdate();