1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Move account login details from settings to persistent storage, with

separate entries depending on server hostname for more convenient
testing
This commit is contained in:
Ivan Savenko
2024-03-29 17:04:52 +02:00
parent 2deca842de
commit 8f0236f046
6 changed files with 104 additions and 28 deletions

View File

@@ -122,8 +122,8 @@ void GlobalLobbyProcessor::onConnectionEstablished(const std::shared_ptr<INetwor
JsonNode toSend;
toSend["type"].String() = "serverLogin";
toSend["gameRoomID"].String() = owner.uuid;
toSend["accountID"] = settings["lobby"]["accountID"];
toSend["accountCookie"] = settings["lobby"]["accountCookie"];
toSend["accountID"].String() = getHostAccountID();
toSend["accountCookie"].String() = getHostAccountCookie();
toSend["version"].String() = VCMI_VERSION_STRING;
sendMessage(connection, toSend);
@@ -140,7 +140,7 @@ void GlobalLobbyProcessor::onConnectionEstablished(const std::shared_ptr<INetwor
toSend["type"].String() = "serverProxyLogin";
toSend["gameRoomID"].String() = owner.uuid;
toSend["guestAccountID"].String() = guestAccountID;
toSend["accountCookie"] = settings["lobby"]["accountCookie"];
toSend["accountCookie"].String() = getHostAccountCookie();
sendMessage(connection, toSend);
@@ -170,3 +170,24 @@ void GlobalLobbyProcessor::sendMessage(const NetworkConnectionPtr & targetConnec
assert(JsonUtils::validate(toSend, "vcmi:lobbyProtocol/" + toSend["type"].String(), toSend["type"].String() + " pack"));
targetConnection->sendPacket(toSend.toBytes());
}
//FIXME: consider whether these methods should be replaced with some other way to define our account ID / account cookie
static const std::string & getServerHost()
{
return settings["lobby"]["hostname"].String();
}
const std::string & GlobalLobbyProcessor::getHostAccountID() const
{
return persistentStorage["lobby"][getServerHost()]["accountID"].String();
}
const std::string & GlobalLobbyProcessor::getHostAccountCookie() const
{
return persistentStorage["lobby"][getServerHost()]["accountCookie"].String();
}
const std::string & GlobalLobbyProcessor::getHostAccountDisplayName() const
{
return persistentStorage["lobby"][getServerHost()]["displayName"].String();
}