Core/bnetserver: Implemented reconnecting with launcherlogin

This commit is contained in:
Shauren
2022-09-13 14:27:54 +02:00
parent 30ad7e3337
commit 8a183a6e5e
6 changed files with 61 additions and 33 deletions

View File

@@ -249,6 +249,36 @@ uint32 Battlenet::Session::HandleVerifyWebCredentials(authentication::v1::Verify
return ERROR_DENIED;
}
uint32 Battlenet::Session::HandleGenerateWebCredentials(authentication::v1::GenerateWebCredentialsRequest const* request, std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)>& continuation)
{
if (!_authed)
return ERROR_DENIED;
if (request->program() != 0x576F57)
{
auto asPrintable = [](char c) { return std::isprint(c) ? c : ' '; };
TC_LOG_DEBUG("session", "[Battlenet::HandleGenerateWebCredentials] %s attempted to generate web cretentials with game other than WoW (using %c%c%c%c)!",
GetClientInfo().c_str(), asPrintable((request->program() >> 24) & 0xFF), asPrintable((request->program() >> 16) & 0xFF),
asPrintable((request->program() >> 8) & 0xFF), asPrintable(request->program() & 0xFF));
return ERROR_BAD_PROGRAM;
}
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_EXISTING_AUTHENTICATION_BY_ID);
stmt->setUInt32(0, _accountInfo->Id);
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback([this, asyncContinuation = std::move(continuation)](PreparedQueryResult result)
{
// just send existing credentials back (not the best but it works for now with them being stored in db)
Battlenet::Services::Authentication asyncContinuationService(this);
authentication::v1::GenerateWebCredentialsResponse response;
response.set_web_credentials((*result)[0].GetCString());
asyncContinuation(&asyncContinuationService, ERROR_OK, &response);
}));
return ERROR_OK;
}
uint32 Battlenet::Session::VerifyWebCredentials(std::string const& webCredentials, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation)
{
if (webCredentials.empty())

View File

@@ -34,43 +34,32 @@ namespace pb = google::protobuf;
class ServiceBase;
namespace bgs
namespace bgs::protocol
{
namespace protocol
{
class Variant;
class Variant;
namespace account
{
namespace v1
{
class GetAccountStateRequest;
class GetAccountStateResponse;
class GetGameAccountStateRequest;
class GetGameAccountStateResponse;
}
}
namespace account::v1
{
class GetAccountStateRequest;
class GetAccountStateResponse;
class GetGameAccountStateRequest;
class GetGameAccountStateResponse;
}
namespace authentication
{
namespace v1
{
class LogonRequest;
class VerifyWebCredentialsRequest;
}
}
namespace authentication::v1
{
class GenerateWebCredentialsRequest;
class LogonRequest;
class VerifyWebCredentialsRequest;
}
namespace game_utilities
{
namespace v1
{
class ClientRequest;
class ClientResponse;
class GetAllValuesForAttributeRequest;
class GetAllValuesForAttributeResponse;
}
}
}
namespace game_utilities::v1
{
class ClientRequest;
class ClientResponse;
class GetAllValuesForAttributeRequest;
class GetAllValuesForAttributeResponse;
}
}
using namespace bgs::protocol;
@@ -144,6 +133,7 @@ namespace Battlenet
uint32 HandleLogon(authentication::v1::LogonRequest const* logonRequest, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation);
uint32 HandleVerifyWebCredentials(authentication::v1::VerifyWebCredentialsRequest const* verifyWebCredentialsRequest, std::function<void(ServiceBase*, uint32, ::google::protobuf::Message const*)>& continuation);
uint32 HandleGenerateWebCredentials(authentication::v1::GenerateWebCredentialsRequest const* request, std::function<void(ServiceBase*, uint32, google::protobuf::Message const*)>& continuation);
uint32 HandleGetAccountState(account::v1::GetAccountStateRequest const* request, account::v1::GetAccountStateResponse* response);
uint32 HandleGetGameAccountState(account::v1::GetGameAccountStateRequest const* request, account::v1::GetGameAccountStateResponse* response);
uint32 HandleProcessClientRequest(game_utilities::v1::ClientRequest const* request, game_utilities::v1::ClientResponse* response);