From 0a3f7da7e74974d785df706dc4c0e4afb0138fac Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Mon, 4 May 2026 20:27:47 +0500 Subject: [PATCH] XboxAuthorizationStep: clang-tidy Signed-off-by: Octol1ttle --- .../auth/steps/XboxAuthorizationStep.cpp | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp index 256031f5f..84320c7c1 100644 --- a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp +++ b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include "Application.h" #include "Logging.h" @@ -12,7 +12,7 @@ #include "net/Upload.h" XboxAuthorizationStep::XboxAuthorizationStep(AccountData* data, Token* token, QString relyingParty, QString authorizationKind) - : AuthStep(data), m_token(token), m_relyingParty(relyingParty), m_authorizationKind(authorizationKind) + : AuthStep(data), m_token(token), m_relyingParty(std::move(relyingParty)), m_authorizationKind(std::move(authorizationKind)) {} QString XboxAuthorizationStep::describe() @@ -22,7 +22,7 @@ QString XboxAuthorizationStep::describe() void XboxAuthorizationStep::perform() { - QString xbox_auth_template = R"XXX( + const QString xboxAuthTemplate = R"XXX( { "Properties": { "SandboxId": "RETAIL", @@ -34,15 +34,13 @@ void XboxAuthorizationStep::perform() "TokenType": "JWT" } )XXX"; - auto xbox_auth_data = xbox_auth_template.arg(m_data->userToken.token, m_relyingParty); + const auto xboxAuthData = xboxAuthTemplate.arg(m_data->userToken.token, m_relyingParty); // http://xboxlive.com - QUrl url("https://xsts.auth.xboxlive.com/xsts/authorize"); - auto headers = QList{ - { "Content-Type", "application/json" }, - { "Accept", "application/json" }, - { "x-xbl-contract-version", "1" } - }; - auto [request, response] = Net::Upload::makeByteArray(url, xbox_auth_data.toUtf8()); + const QUrl url("https://xsts.auth.xboxlive.com/xsts/authorize"); + auto headers = QList{ { .headerName = "Content-Type", .headerValue = "application/json" }, + { .headerName = "Accept", .headerValue = "application/json" }, + { .headerName = "x-xbl-contract-version", .headerValue = "1" } }; + auto [request, response] = Net::Upload::makeByteArray(url, xboxAuthData.toUtf8()); m_request = request; m_request->addHeaderProxy(std::make_unique(headers)); m_request->enableAutoRetry(true); @@ -97,8 +95,8 @@ bool XboxAuthorizationStep::processSTSError(const QByteArray& response) { if (m_request->error() == QNetworkReply::AuthenticationRequiredError) { QJsonParseError jsonError; - QJsonDocument doc = QJsonDocument::fromJson(response, &jsonError); - if (jsonError.error) { + const QJsonDocument doc = QJsonDocument::fromJson(response, &jsonError); + if (jsonError.error != QJsonParseError::NoError) { qWarning() << "Cannot parse error XSTS response as JSON:" << jsonError.errorString(); emit finished(AccountTaskState::STATE_FAILED_SOFT, tr("Cannot parse %1 authorization error response as JSON: %2").arg(m_authorizationKind, jsonError.errorString()));