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

Fixed up json object and added lobbyPort for api response

This commit is contained in:
Toofy 2024-01-23 23:38:23 +00:00
parent b3e86d3877
commit 3bf03c54f4

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 )