mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-03 17:32:33 +00:00
Add DatabaseMySQL::DoesLoginServerAccountExist
This commit is contained in:
parent
d40b95f2e8
commit
eea3965d02
@ -590,6 +590,7 @@ void Client::DoSuccessfulLogin(const std::string &user, int db_account_id, const
|
|||||||
in.s_addr = connection->GetRemoteIP();
|
in.s_addr = connection->GetRemoteIP();
|
||||||
|
|
||||||
server.db->UpdateLSAccountData(db_account_id, std::string(inet_ntoa(in)));
|
server.db->UpdateLSAccountData(db_account_id, std::string(inet_ntoa(in)));
|
||||||
|
|
||||||
GenerateKey();
|
GenerateKey();
|
||||||
|
|
||||||
account_id = db_account_id;
|
account_id = db_account_id;
|
||||||
@ -674,6 +675,11 @@ void Client::CreateEQEmuAccount(const std::string &user, const std::string &pass
|
|||||||
auto mode = server.options.GetEncryptionMode();
|
auto mode = server.options.GetEncryptionMode();
|
||||||
auto hash = eqcrypt_hash(user, pass, mode);
|
auto hash = eqcrypt_hash(user, pass, mode);
|
||||||
|
|
||||||
|
if (server.db->DoesLoginServerAccountExist(user, hash, "eqemu", id)) {
|
||||||
|
DoSuccessfulLogin(user, id, "eqemu");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!server.db->CreateLoginDataWithID(user, hash, "eqemu", id)) {
|
if (!server.db->CreateLoginDataWithID(user, hash, "eqemu", id)) {
|
||||||
DoFailedLogin();
|
DoFailedLogin();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -322,6 +322,39 @@ bool DatabaseMySQL::CreateLoginDataWithID(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @param password
|
||||||
|
* @param loginserver
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
bool DatabaseMySQL::DoesLoginServerAccountExist(
|
||||||
|
const std::string &name,
|
||||||
|
const std::string &password,
|
||||||
|
const std::string &loginserver,
|
||||||
|
unsigned int id
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (id == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto query = fmt::format(
|
||||||
|
"SELECT AccountName FROM {0} WHERE AccountName = '{1}' AND AccountLoginserver = '{2}'",
|
||||||
|
server.options.GetAccountTable(),
|
||||||
|
EscapeString(name),
|
||||||
|
EscapeString(loginserver)
|
||||||
|
);
|
||||||
|
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success() || results.RowCount() != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param loginserver
|
* @param loginserver
|
||||||
|
|||||||
@ -87,8 +87,16 @@ public:
|
|||||||
const std::string &loginserver,
|
const std::string &loginserver,
|
||||||
unsigned int id
|
unsigned int id
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual void UpdateLoginHash(const std::string &name, const std::string &loginserver, const std::string &hash);
|
virtual void UpdateLoginHash(const std::string &name, const std::string &loginserver, const std::string &hash);
|
||||||
|
|
||||||
|
virtual bool DoesLoginServerAccountExist(
|
||||||
|
const std::string &name,
|
||||||
|
const std::string &password,
|
||||||
|
const std::string &loginserver,
|
||||||
|
unsigned int id
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the world registration from the long and short names provided
|
* Retrieves the world registration from the long and short names provided
|
||||||
* Needed for world login procedure
|
* Needed for world login procedure
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public:
|
|||||||
LoginServer() : db(nullptr), server_manager(nullptr) { }
|
LoginServer() : db(nullptr), server_manager(nullptr) { }
|
||||||
|
|
||||||
EQ::JsonConfigFile config;
|
EQ::JsonConfigFile config;
|
||||||
Database *db;
|
DatabaseMySQL *db;
|
||||||
Options options;
|
Options options;
|
||||||
ServerManager *server_manager;
|
ServerManager *server_manager;
|
||||||
ClientManager *client_manager;
|
ClientManager *client_manager;
|
||||||
|
|||||||
@ -133,7 +133,7 @@ int main()
|
|||||||
*/
|
*/
|
||||||
Log(Logs::General, Logs::Login_Server, "MySQL Database Init.");
|
Log(Logs::General, Logs::Login_Server, "MySQL Database Init.");
|
||||||
|
|
||||||
server.db = (Database *) new DatabaseMySQL(
|
server.db = new DatabaseMySQL(
|
||||||
server.config.GetVariableString("database", "user", "root"),
|
server.config.GetVariableString("database", "user", "root"),
|
||||||
server.config.GetVariableString("database", "password", ""),
|
server.config.GetVariableString("database", "password", ""),
|
||||||
server.config.GetVariableString("database", "host", "localhost"),
|
server.config.GetVariableString("database", "host", "localhost"),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user