From ad8aeb0b2bdfd7586beab0be31bc36c64da31092 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 14 Nov 2013 14:32:43 -0600 Subject: Implement auth task's response processing. The authenticate task can now successfully log a user in. --- logic/auth/YggdrasilTask.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'logic/auth/YggdrasilTask.cpp') diff --git a/logic/auth/YggdrasilTask.cpp b/logic/auth/YggdrasilTask.cpp index efc6ec96..a023b07e 100644 --- a/logic/auth/YggdrasilTask.cpp +++ b/logic/auth/YggdrasilTask.cpp @@ -20,12 +20,14 @@ #include #include #include +#include #include #include YggdrasilTask::YggdrasilTask(MojangAccount* account, QObject* parent) : Task(parent) { + m_error = nullptr; m_account = account; } @@ -45,7 +47,7 @@ void YggdrasilTask::executeTask() auto worker = MMC->qnam(); connect(worker.get(), SIGNAL(finished(QNetworkReply*)), this, - SLOT(processResponse(QNetworkReply*))); + SLOT(processReply(QNetworkReply*))); QUrl reqUrl("https://authserver.mojang.com/" + getEndpoint()); QNetworkRequest netRequest(reqUrl); @@ -70,7 +72,8 @@ void YggdrasilTask::processReply(QNetworkReply* reply) // Try to parse the response regardless of the response code. // Sometimes the auth server will give more information and an error code. QJsonParseError jsonError; - QJsonDocument doc = QJsonDocument::fromJson(reply->readAll(), &jsonError); + QByteArray replyData = reply->readAll(); + QJsonDocument doc = QJsonDocument::fromJson(replyData, &jsonError); // Check the response code. int responseCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); @@ -91,6 +94,10 @@ void YggdrasilTask::processReply(QNetworkReply* reply) else emitFailed(tr("An unknown error occurred when processing the response from the authentication server.")); } + else + { + emitSucceeded(); + } break; default: @@ -150,7 +157,7 @@ QString YggdrasilTask::processError(QJsonObject responseData) } } -QString YggdrasilTask::getStateMessage(const YggdrasilTask::State state) +QString YggdrasilTask::getStateMessage(const YggdrasilTask::State state) const { switch (state) { -- cgit v1.2.3