EQMacEmu / Server

Other
28 stars 96 forks source link

Fix tblLoginServerAccounts #38

Open xackery opened 6 months ago

xackery commented 6 months ago
[Login] [Info] platform : PC , username : xackery is created
[Login] [MySQL Error] [1364] [Field 'creationIP' doesn't have a default value]
[INSERT INTO tblLoginServerAccounts (AccountName, AccountPassword, AccountEmail, LastLoginDate, LastIPAddress)  VALUES('xackery', SHA('nothing'), 'local_creation', NOW(), '127.0.0.1'); ]
[Login] [Error] Account did not existed in the database for xackery 
[Login] [Info] Client disconnected from the server, removing client.

seems image

then

 Error] [1364] [Field 'ForumName' doesn't have a default value]
[INSERT INTO tblLoginServerAccounts (AccountName, AccountPassword, AccountEmail, LastLoginDate, LastIPAddress, creationIP)  VALUES('xackery', SHA('nothing'), 'local_creation', NOW(), '127.0.0.1', '127.0.0.1'); ]
xackery commented 6 months ago

Here's a fix diff:

diff --git a/loginserver/database.cpp b/loginserver/database.cpp
index 021c4e1..2e5ffd8 100644
--- a/loginserver/database.cpp
+++ b/loginserver/database.cpp
@@ -136,8 +136,8 @@ bool Database::CreateLoginData(const std::string &name, const std::string &passw

    id = atoi(row[0]);

-   auto insert_query = fmt::format("INSERT INTO {0} (AccountName, AccountPassword, AccountEmail, LastLoginDate, LastIPAddress) "
-       " VALUES('{1}', SHA('{2}'), 'local_creation', NOW(), '127.0.0.1'); ",
+   auto insert_query = fmt::format("INSERT INTO {0} (AccountName, AccountPassword, AccountEmail, LastLoginDate, LastIPAddress, creationIP, forumname) "
+       " VALUES('{1}', SHA('{2}'), 'local_creation', NOW(), '127.0.0.1', '127.0.0.1', ''); ",
        server.options.GetAccountTable(),
        Strings::Escape(name),
        Strings::Escape(password)
@@ -354,7 +354,7 @@ std::string Database::LoginSettings(std::string type)
    return value.c_str();
 }

-bool Database::CheckSettings(int type) 
+bool Database::CheckSettings(int type)
 {
    if (type == 1)
    {
jcon321 commented 5 months ago

Just a note about this issue... I'd ensure TAKP prod login.ini auto_create_accounts is FALSE before implementing above diff (99% sure it is). But just in case this bug was indirectly preventing auto creation.

I 2nd this diff - atm I have to include a sql file for devcontainer spin up. When this issue is closed I'll remove the manual injected sql file fix in devcontainer.