diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-12-05 02:39:52 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-12-05 02:39:52 +0100 |
commit | f028aa76bc5d28b7fc4d1ea4e194895690e9944e (patch) | |
tree | 5157fb0c4675c7f6f14c3947ab685f3b87d45610 /logic/auth/flows/RefreshTask.cpp | |
parent | 613699b3626aea750093ab7eaaeccaa28c0e87c6 (diff) | |
download | MultiMC-f028aa76bc5d28b7fc4d1ea4e194895690e9944e.tar MultiMC-f028aa76bc5d28b7fc4d1ea4e194895690e9944e.tar.gz MultiMC-f028aa76bc5d28b7fc4d1ea4e194895690e9944e.tar.lz MultiMC-f028aa76bc5d28b7fc4d1ea4e194895690e9944e.tar.xz MultiMC-f028aa76bc5d28b7fc4d1ea4e194895690e9944e.zip |
Offline mode support, part 1
Refactor MojangAccount so it exposes a less generic interface and supports login. Hide the ugly details.
Yggdrasil tasks are now only used from MojangAccount.
Diffstat (limited to 'logic/auth/flows/RefreshTask.cpp')
-rw-r--r-- | logic/auth/flows/RefreshTask.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/logic/auth/flows/RefreshTask.cpp b/logic/auth/flows/RefreshTask.cpp index b56ed9bc..39fb493f 100644 --- a/logic/auth/flows/RefreshTask.cpp +++ b/logic/auth/flows/RefreshTask.cpp @@ -25,7 +25,7 @@ #include "logger/QsLog.h" -RefreshTask::RefreshTask(MojangAccountPtr account, QObject *parent) +RefreshTask::RefreshTask(MojangAccount *account, QObject *parent) : YggdrasilTask(account, parent) { } @@ -44,13 +44,12 @@ QJsonObject RefreshTask::getRequestContent() const * "requestUser": true/false // request the user structure * } */ - auto account = getMojangAccount(); QJsonObject req; - req.insert("clientToken", account->clientToken()); - req.insert("accessToken", account->accessToken()); + req.insert("clientToken", m_account->m_clientToken); + req.insert("accessToken", m_account->m_accessToken); /* { - auto currentProfile = account->currentProfile(); + auto currentProfile = m_account->currentProfile(); QJsonObject profile; profile.insert("id", currentProfile->id()); profile.insert("name", currentProfile->name()); @@ -64,8 +63,6 @@ QJsonObject RefreshTask::getRequestContent() const bool RefreshTask::processResponse(QJsonObject responseData) { - auto account = getMojangAccount(); - // Read the response data. We need to get the client token, access token, and the selected // profile. QLOG_DEBUG() << "Processing authentication response."; @@ -80,7 +77,7 @@ bool RefreshTask::processResponse(QJsonObject responseData) QLOG_ERROR() << "Server didn't send a client token."; return false; } - if (!account->clientToken().isEmpty() && clientToken != account->clientToken()) + if (!m_account->m_clientToken.isEmpty() && clientToken != m_account->m_clientToken) { // The server changed our client token! Obey its wishes, but complain. That's what I do // for my parents, so... @@ -104,7 +101,7 @@ bool RefreshTask::processResponse(QJsonObject responseData) // profile) QJsonObject currentProfile = responseData.value("selectedProfile").toObject(); QString currentProfileId = currentProfile.value("id").toString(""); - if (account->currentProfile()->id() != currentProfileId) + if (m_account->currentProfile()->id != currentProfileId) { // TODO: Set an error to display to the user. QLOG_ERROR() << "Server didn't specify the same selected profile as ours."; @@ -132,8 +129,7 @@ bool RefreshTask::processResponse(QJsonObject responseData) // we've succeeded. QLOG_DEBUG() << "Finished reading refresh response."; // Reset the access token. - account->setAccessToken(accessToken); - account->propagateChange(); + m_account->m_accessToken = accessToken; return true; } |