Browse Source

Merge pull request 'Feature-AutoRegister' (#1) from Feature-AutoRegister into master

Reviewed-on: MagicBane/Server#1
master
MagicBot 3 years ago
parent
commit
c45491a3d2
  1. 8
      src/engine/db/handlers/dbAccountHandler.java
  2. 1
      src/engine/gameManager/ConfigManager.java
  3. 21
      src/engine/server/login/LoginServerMsgHandler.java

8
src/engine/db/handlers/dbAccountHandler.java

@ -121,6 +121,14 @@ public class dbAccountHandler extends dbHandlerBase { @@ -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)

1
src/engine/gameManager/ConfigManager.java

@ -46,6 +46,7 @@ public enum ConfigManager { @@ -46,6 +46,7 @@ public enum ConfigManager {
// Login server config
MB_LOGIN_PORT,
MB_LOGIN_AUTOREG,
MB_MAJOR_VER,
MB_MINOR_VER,

21
src/engine/server/login/LoginServerMsgHandler.java

@ -12,6 +12,7 @@ package engine.server.login; @@ -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 { @@ -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())

Loading…
Cancel
Save