Commit fda20501 authored by Melledy's avatar Melledy
Browse files

Fix account not found issue when logging in

parent 88e608ad
...@@ -226,18 +226,22 @@ public final class DispatchServer { ...@@ -226,18 +226,22 @@ public final class DispatchServer {
Account account = DatabaseHelper.getAccountByName(requestData.account); Account account = DatabaseHelper.getAccountByName(requestData.account);
// Check if account exists, else create a new one. // Check if account exists, else create a new one.
if (account == null && Grasscutter.getConfig().ServerOptions.AutomaticallyCreateAccounts) { if (account == null) {
// This account has been created AUTOMATICALLY. There will be no permissions added. // Account doesnt exist, so we can either auto create it if the config value is set
account = DatabaseHelper.createAccountWithId(requestData.account, 0); if (Grasscutter.getConfig().ServerOptions.AutomaticallyCreateAccounts) {
// This account has been created AUTOMATICALLY. There will be no permissions added.
responseData.message = "OK"; account = DatabaseHelper.createAccountWithId(requestData.account, 0);
responseData.data.account.uid = account.getId();
responseData.data.account.token = account.generateSessionKey(); responseData.message = "OK";
responseData.data.account.email = account.getEmail(); responseData.data.account.uid = account.getId();
} else if (!Grasscutter.getConfig().ServerOptions.AutomaticallyCreateAccounts) { responseData.data.account.token = account.generateSessionKey();
responseData.retcode = -201; responseData.data.account.email = account.getEmail();
responseData.message = "Username not found."; } else {
responseData.retcode = -201;
responseData.message = "Username not found.";
}
} else { } else {
// Account was found, log the player in
responseData.message = "OK"; responseData.message = "OK";
responseData.data.account.uid = account.getId(); responseData.data.account.uid = account.getId();
responseData.data.account.token = account.generateSessionKey(); responseData.data.account.token = account.generateSessionKey();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment