mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
Take in API requests via json payload instead of params
This commit is contained in:
parent
5473457c0c
commit
c2917a9004
@ -6,16 +6,8 @@
|
||||
#EQEMU_DISABLE_SAFESEH
|
||||
#EQEMU_BUILD_MSVC_MP
|
||||
#EQEMU_DEBUG_LEVEL
|
||||
#EQEMU_LOG_LEVEL_STATUS
|
||||
#EQEMU_LOG_LEVEL_NORMAL
|
||||
#EQEMU_LOG_LEVEL_ERROR
|
||||
#EQEMU_LOG_LEVEL_DEBUG
|
||||
#EQEMU_LOG_LEVEL_QUEST
|
||||
#EQEMU_LOG_LEVEL_COMMANDS
|
||||
#EQEMU_LOG_LEVEL_CRASH
|
||||
#EQEMU_DEPOP_INVALIDATES_CACHE
|
||||
#EQEMU_ENABLE_BOTS
|
||||
#EQEMU_DISABLE_LOGSYS
|
||||
#EQEMU_COMMANDS_LOGGING
|
||||
#EQEMU_BUILD_SERVER
|
||||
#EQEMU_BUILD_LOGIN
|
||||
@ -144,36 +136,6 @@ SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
|
||||
10 - More errors than you ever wanted to see"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_STATUS 2 CACHE STRING "EQEmu logging level for [Status]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_NORMAL 3 CACHE STRING "EQEmu logging level for [Normal]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_ERROR 2 CACHE STRING "EQEmu logging level for [Error]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
@ -184,47 +146,17 @@ SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_QUEST 2 CACHE STRING "EQEmu logging level for [Quest]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
OPTION(EQEMU_LSPX "" OFF)
|
||||
IF(EQEMU_LSPX)
|
||||
ADD_DEFINITIONS(-DLSPX=ON)
|
||||
ENDIF(EQEMU_LSPX)
|
||||
MARK_AS_ADVANCED(EQEMU_LSPX)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_COMMANDS 1 CACHE STRING "EQEmu logging level for [Commands]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_CRASH 3 CACHE STRING "EQEmu logging level for [Crash]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_STATUS EQEMU_LOG_LEVEL_NORMAL EQEMU_LOG_LEVEL_ERROR EQEMU_LOG_LEVEL_DEBUG EQEMU_LOG_LEVEL_QUEST EQEMU_LOG_LEVEL_COMMANDS EQEMU_LOG_LEVEL_CRASH)
|
||||
|
||||
#NPC Types Cache Behavior
|
||||
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
|
||||
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_DEBUG)
|
||||
|
||||
#Bots are a compile time option so on/off
|
||||
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
|
||||
|
||||
#Disable entire _mlog system (excludes trade/command logs)
|
||||
OPTION(EQEMU_DISABLE_LOGSYS "Disable Logging INI System" ON)
|
||||
|
||||
#Enable GM Command log system
|
||||
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
|
||||
|
||||
@ -232,10 +164,6 @@ IF(EQEMU_COMMANDS_LOGGING)
|
||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
||||
ENDIF(EQEMU_COMMANDS_LOGGING)
|
||||
|
||||
IF(EQEMU_DISABLE_LOGSYS)
|
||||
ADD_DEFINITIONS(-DDISABLE_LOGSYS)
|
||||
ENDIF(EQEMU_DISABLE_LOGSYS)
|
||||
|
||||
IF(EQEMU_ENABLE_BOTS)
|
||||
ADD_DEFINITIONS(-DBOTS)
|
||||
ENDIF(EQEMU_ENABLE_BOTS)
|
||||
@ -278,13 +206,7 @@ ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
|
||||
ADD_DEFINITIONS(-DINVERSEXY)
|
||||
ADD_DEFINITIONS(-DFIELD_ITEMS)
|
||||
ADD_DEFINITIONS(-DMAP_DIR="${EQEMU_MAP_DIR}")
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_STATUS=${EQEMU_LOG_LEVEL_STATUS})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_NORMAL=${EQEMU_LOG_LEVEL_NORMAL})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_ERROR=${EQEMU_LOG_LEVEL_ERROR})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_DEBUG=${EQEMU_LOG_LEVEL_DEBUG})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_QUEST=${EQEMU_LOG_LEVEL_QUEST})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_COMMANDS=${EQEMU_LOG_LEVEL_COMMANDS})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_CRASH=${EQEMU_LOG_LEVEL_CRASH})
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_CTOR_INIT)
|
||||
ADD_DEFINITIONS(-DGLM_ENABLE_EXPERIMENTAL)
|
||||
|
||||
@ -385,8 +385,9 @@ void Client::AttemptLoginAccountCreation(
|
||||
{
|
||||
LogInfo("Attempting login account creation via '{0}'", loginserver);
|
||||
|
||||
if (loginserver == "eqemu") {
|
||||
#ifdef LSPX
|
||||
|
||||
if (loginserver == "eqemu") {
|
||||
if (!server.options.CanAutoLinkAccounts()) {
|
||||
LogInfo("CanAutoLinkAccounts disabled - sending failed login");
|
||||
DoFailedLogin();
|
||||
@ -445,16 +446,17 @@ void Client::AttemptLoginAccountCreation(
|
||||
login_connection_manager->Connect(addr, port);
|
||||
}
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
||||
if (!server.options.CanAutoCreateAccounts()) {
|
||||
DoFailedLogin();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (server.options.CanAutoCreateAccounts() && loginserver == "local") {
|
||||
CreateLocalAccount(user, pass);
|
||||
return;
|
||||
}
|
||||
|
||||
CreateLocalAccount(user, pass);
|
||||
}
|
||||
DoFailedLogin();
|
||||
}
|
||||
|
||||
void Client::DoFailedLogin()
|
||||
|
||||
@ -277,7 +277,7 @@ bool Database::DoesLoginServerAccountExist(
|
||||
}
|
||||
|
||||
auto query = fmt::format(
|
||||
"SELECT AccountName FROM login_accounts WHERE account_name = '{0}' AND source_loginserver = '{1}'",
|
||||
"SELECT account_name FROM login_accounts WHERE account_name = '{0}' AND source_loginserver = '{1}'",
|
||||
EscapeString(name),
|
||||
EscapeString(loginserver)
|
||||
);
|
||||
|
||||
@ -64,13 +64,18 @@ namespace LoginserverWebserver {
|
||||
api.Post(
|
||||
"/account/create", [](const httplib::Request &request, httplib::Response &res) {
|
||||
LoginserverWebserver::TokenManager::AuthCanWrite(request, res);
|
||||
Json::Value request_body = LoginserverWebserver::ParseRequestBody(request);
|
||||
std::string username = request_body.get("username", "").asString();
|
||||
std::string password = request_body.get("password", "").asString();
|
||||
|
||||
Json::Value response;
|
||||
bool account_created = AccountManagement::CreateLocalLoginServerAccount(
|
||||
request.get_param_value("username"),
|
||||
request.get_param_value("password")
|
||||
);
|
||||
if (username.empty() || password.empty()) {
|
||||
response["message"] = "Username or password not set";
|
||||
LoginserverWebserver::SendResponse(response, res);
|
||||
return;
|
||||
}
|
||||
|
||||
bool account_created = AccountManagement::CreateLocalLoginServerAccount(username, password);
|
||||
if (account_created) {
|
||||
response["message"] = "Account created successfully!";
|
||||
}
|
||||
@ -108,6 +113,20 @@ namespace LoginserverWebserver {
|
||||
res.set_content(response_payload.str(), "application/json");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param payload
|
||||
* @param res
|
||||
*/
|
||||
Json::Value ParseRequestBody(const httplib::Request &request)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss.str(request.body);
|
||||
Json::Value request_body;
|
||||
ss >> request_body;
|
||||
|
||||
return request_body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @param res
|
||||
|
||||
@ -52,6 +52,7 @@ namespace LoginserverWebserver {
|
||||
|
||||
void RegisterRoutes(httplib::Server &api);
|
||||
void SendResponse(const Json::Value &payload, httplib::Response &res);
|
||||
static Json::Value ParseRequestBody(const httplib::Request &request);
|
||||
};
|
||||
|
||||
#endif //EQEMU_LOGINSERVER_WEBSERVER_H
|
||||
|
||||
@ -96,28 +96,6 @@ int main(int argc, char** argv)
|
||||
true
|
||||
)
|
||||
);
|
||||
server.options.AccountTable(server.config.GetVariableString("schema", "account_table", "tblLoginServerAccounts"));
|
||||
server.options.WorldRegistrationTable(
|
||||
server.config.GetVariableString(
|
||||
"schema",
|
||||
"world_registration_table",
|
||||
"tblWorldServerRegistration"
|
||||
)
|
||||
);
|
||||
server.options.WorldAdminRegistrationTable(
|
||||
server.config.GetVariableString(
|
||||
"schema",
|
||||
"world_admin_registration_table",
|
||||
"tblServerAdminRegistration"
|
||||
)
|
||||
);
|
||||
server.options.WorldServerTypeTable(
|
||||
server.config.GetVariableString(
|
||||
"schema",
|
||||
"world_server_type_table",
|
||||
"tblServerListType"
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* mysql connect
|
||||
|
||||
@ -102,46 +102,6 @@ public:
|
||||
*/
|
||||
inline int GetEncryptionMode() const { return encryption_mode; }
|
||||
|
||||
/**
|
||||
* Sets account table.
|
||||
*/
|
||||
inline void AccountTable(std::string t) { account_table = t; }
|
||||
|
||||
/**
|
||||
* Return the value of world account table.
|
||||
*/
|
||||
inline std::string GetAccountTable() const { return account_table; }
|
||||
|
||||
/**
|
||||
* Sets world registration table.
|
||||
*/
|
||||
inline void WorldRegistrationTable(std::string t) { world_registration_table = t; }
|
||||
|
||||
/**
|
||||
* Return the value of world registration table.
|
||||
*/
|
||||
inline std::string GetWorldRegistrationTable() const { return world_registration_table; }
|
||||
|
||||
/**
|
||||
* Sets world admin account table.
|
||||
*/
|
||||
inline void WorldAdminRegistrationTable(std::string t) { world_admin_registration_table = t; }
|
||||
|
||||
/**
|
||||
* Return the value of world admin account table.
|
||||
*/
|
||||
inline std::string GetWorldAdminRegistrationTable() const { return world_admin_registration_table; }
|
||||
|
||||
/**
|
||||
* Sets world server type table.
|
||||
*/
|
||||
inline void WorldServerTypeTable(std::string t) { world_server_type_table = t; }
|
||||
|
||||
/**
|
||||
* Return the value of world server type table.
|
||||
*/
|
||||
inline std::string GetWorldServerTypeTable() const { return world_server_type_table; }
|
||||
|
||||
/**
|
||||
* Sets whether we are rejecting duplicate servers or not.
|
||||
*/
|
||||
@ -186,10 +146,6 @@ private:
|
||||
bool auto_link_accounts;
|
||||
bool update_insecure_passwords;
|
||||
int encryption_mode;
|
||||
std::string account_table;
|
||||
std::string world_registration_table;
|
||||
std::string world_admin_registration_table;
|
||||
std::string world_server_type_table;
|
||||
std::string eqemu_loginserver_address;
|
||||
std::string default_loginserver_name;
|
||||
};
|
||||
|
||||
@ -250,10 +250,6 @@ SET(zone_headers
|
||||
zonedb.h
|
||||
zonedump.h)
|
||||
|
||||
IF(EQEMU_DEPOP_INVALIDATES_CACHE)
|
||||
ADD_DEFINITIONS(-DDEPOP_INVALIDATES_NPC_TYPES_CACHE)
|
||||
ENDIF(EQEMU_DEPOP_INVALIDATES_CACHE)
|
||||
|
||||
ADD_EXECUTABLE(zone ${zone_sources} ${zone_headers})
|
||||
|
||||
INSTALL(TARGETS zone RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user