Core/bnetserver: Implemented reconnecting with launcherlogin

Port From (https://github.com/TrinityCore/TrinityCore/commit/8a183a6e5ee1cd394aabb9df4e34064466bd3946)
This commit is contained in:
hondacrx
2022-09-18 15:24:59 -04:00
parent 1f01e15e09
commit 3fe93e9a1c
2 changed files with 27 additions and 1 deletions
@@ -42,7 +42,7 @@ namespace BNetServer.Networking
var endpoint = Global.LoginServiceMgr.GetAddressForClient(GetRemoteIpEndPoint().Address);
ChallengeExternalRequest externalChallenge = new();
externalChallenge.PayloadType = "web_auth_url";
externalChallenge.PayloadType = "web_auth_url";
externalChallenge.Payload = ByteString.CopyFromUtf8($"https://{endpoint.Address}:{endpoint.Port}/bnetserver/login/");
SendRequest((uint)OriginalHash.ChallengeListener, 3, externalChallenge);
@@ -164,5 +164,29 @@ namespace BNetServer.Networking
SendRequest((uint)OriginalHash.AuthenticationListener, 5, logonResult);
return BattlenetRpcErrorCode.Ok;
}
[Service(OriginalHash.AuthenticationService, 8)]
BattlenetRpcErrorCode HandleGenerateWebCredentials(GenerateWebCredentialsRequest request, GenerateWebCredentialsResponse response)
{
if (!authed)
return BattlenetRpcErrorCode.Denied;
if (request.Program != 0x576F57)
{
Log.outDebug(LogFilter.Session, $"[Battlenet::HandleGenerateWebCredentials] {GetClientInfo()} attempted to generate web cretentials with game other than WoW (using {(request.Program >> 24) & 0xFF}{(request.Program >> 16) & 0xFF}{(request.Program >> 8) & 0xFF}{request.Program & 0xFF})!");
return BattlenetRpcErrorCode.BadProgram;
}
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_BNET_EXISTING_AUTHENTICATION_BY_ID);
stmt.AddValue(0, accountInfo.Id);
queryProcessor.AddCallback(DB.Login.AsyncQuery(stmt).WithCallback(result =>
{
// just send existing credentials back (not the best but it works for now with them being stored in db)
response.WebCredentials = ByteString.CopyFromUtf8(result.Read<string>(0));
}));
return BattlenetRpcErrorCode.Ok;
}
}
}
@@ -114,6 +114,7 @@ namespace Framework.Database
PrepareStatement(LoginStatements.SelBnetAuthentication, "SELECT ba.id, ba.sha_pass_hash, ba.failed_logins, ba.LoginTicket, ba.LoginTicketExpiry, bab.unbandate > UNIX_TIMESTAMP() OR bab.unbandate = bab.bandate FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id WHERE email = ?");
PrepareStatement(LoginStatements.UpdBnetAuthentication, "UPDATE battlenet_accounts SET LoginTicket = ?, LoginTicketExpiry = ? WHERE id = ?");
PrepareStatement(LoginStatements.SEL_BNET_EXISTING_AUTHENTICATION_BY_ID, "SELECT LoginTicket FROM battlenet_accounts WHERE id = ?");
PrepareStatement(LoginStatements.SelBnetAccountInfo, "SELECT " + BnetAccountInfo + ", " + BnetGameAccountInfo +
" FROM battlenet_accounts ba LEFT JOIN battlenet_account_bans bab ON ba.id = bab.id LEFT JOIN account a ON ba.id = a.battlenet_account" +
" LEFT JOIN account_banned ab ON a.id = ab.id AND ab.active = 1 LEFT JOIN account_access aa ON a.id = aa.AccountID AND aa.RealmID = -1 WHERE ba.LoginTicket = ? ORDER BY a.id");
@@ -264,6 +265,7 @@ namespace Framework.Database
SelBnetAuthentication,
UpdBnetAuthentication,
SEL_BNET_EXISTING_AUTHENTICATION_BY_ID,
SelBnetAccountInfo,
UpdBnetLastLoginInfo,
UPD_BNET_GAME_ACCOUNT_LOGIN_INFO,