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. 15
      src/engine/server/login/LoginServerMsgHandler.java

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

@ -121,6 +121,14 @@ public class dbAccountHandler extends dbHandlerBase {
executeUpdate(); 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) { public Account GET_ACCOUNT(String uname) {
if (Account.AccountsMap.get(uname) != null) if (Account.AccountsMap.get(uname) != null)

1
src/engine/gameManager/ConfigManager.java

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

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

@ -12,6 +12,7 @@ package engine.server.login;
import engine.Enum; import engine.Enum;
import engine.Enum.DispatchChannel; import engine.Enum.DispatchChannel;
import engine.Enum.GameObjectType; import engine.Enum.GameObjectType;
import engine.gameManager.ConfigManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.job.JobScheduler; import engine.job.JobScheduler;
@ -174,12 +175,26 @@ public class LoginServerMsgHandler implements NetMsgHandler {
account = DbManager.AccountQueries.GET_ACCOUNT(uname); 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) { if (account == null) {
if (ConfigManager.MB_LOGIN_AUTOREG.getValue().equals("FALSE")) {
this.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', clientConnection); this.KickToLogin(MBServerStatics.LOGINERROR_INVALID_USERNAME_PASSWORD, "Could not find account (" + uname + ')', clientConnection);
Logger.info("Could not find account (" + uname + ')'); Logger.info("Could not find account (" + uname + ')');
return; 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()) if (account.getLastLoginFailure() + MBServerStatics.RESET_LOGIN_ATTEMPTS_AFTER < System.currentTimeMillis())

Loading…
Cancel
Save