1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 16:57:47 +00:00

Merge pull request #953 from T00fy/wip

Fixed up json object and added lobbyPort for api response
This commit is contained in:
Adam 2024-05-13 23:32:20 +10:00 committed by GitHub
commit 989630b2ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -244,12 +244,14 @@ void createAccount( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
std::string sId; std::string sId;
if( g_sapphireAPI.createAccount( user, pass, sId ) ) if( g_sapphireAPI.createAccount( user, pass, sId ) )
{ {
// todo: construct proper json object here nlohmann::json response_json = {
std::string json_string = "{\"sId\":\"" + sId + {"sId", sId},
"\", \"lobbyHost\":\"" + {"lobbyHost", m_config.global.network.lobbyHost},
m_config.global.network.lobbyHost + {"frontierHost", m_config.global.network.restHost},
"\", \"frontierHost\":\"" + {"lobbyPort", m_config.global.network.lobbyPort}
m_config.global.network.restHost + "\"}"; };
std::string json_string = response_json.dump();
*response << buildHttpResponse( 200, json_string, JSON ); *response << buildHttpResponse( 200, json_string, JSON );
} }
else else
@ -277,12 +279,15 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
// reloadConfig(); // reloadConfig();
if( g_sapphireAPI.login( user, pass, sId ) ) if( g_sapphireAPI.login( user, pass, sId ) )
{ {
// todo: build proper json object and stringify it nlohmann::json response_json = {
std::string json_string = "{\"sId\":\"" + sId + {"sId", sId},
"\", \"lobbyHost\":\"" + {"lobbyHost", m_config.global.network.lobbyHost},
m_config.global.network.lobbyHost + {"frontierHost", m_config.global.network.restHost},
"\", \"frontierHost\":\"" + {"lobbyPort", m_config.global.network.lobbyPort}
m_config.global.network.restHost + "\"}"; };
std::string json_string = response_json.dump();
*response << buildHttpResponse( 200, json_string, JSON ); *response << buildHttpResponse( 200, json_string, JSON );
} }
else else
@ -294,7 +299,6 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer:
*response << buildHttpResponse( 500 ); *response << buildHttpResponse( 500 );
Logger::error( e.what() ); Logger::error( e.what() );
} }
} }
void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer::Request > request ) void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer::Request > request )