summaryrefslogtreecommitdiffstats
path: root/logic/auth/flows/AuthenticateTask.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logic/auth/flows/AuthenticateTask.cpp')
-rw-r--r--logic/auth/flows/AuthenticateTask.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/logic/auth/flows/AuthenticateTask.cpp b/logic/auth/flows/AuthenticateTask.cpp
index ec2004d6..966548ec 100644
--- a/logic/auth/flows/AuthenticateTask.cpp
+++ b/logic/auth/flows/AuthenticateTask.cpp
@@ -26,7 +26,7 @@
#include "logger/QsLog.h"
-AuthenticateTask::AuthenticateTask(MojangAccountPtr account, const QString &password,
+AuthenticateTask::AuthenticateTask(MojangAccount * account, const QString &password,
QObject *parent)
: YggdrasilTask(account, parent), m_password(password)
{
@@ -59,14 +59,14 @@ QJsonObject AuthenticateTask::getRequestContent() const
req.insert("agent", agent);
}
- req.insert("username", getMojangAccount()->username());
+ req.insert("username", m_account->username());
req.insert("password", m_password);
req.insert("requestUser", true);
// If we already have a client token, give it to the server.
// Otherwise, let the server give us one.
- if (!getMojangAccount()->clientToken().isEmpty())
- req.insert("clientToken", getMojangAccount()->clientToken());
+ if (!m_account->m_clientToken.isEmpty())
+ req.insert("clientToken", m_account->m_clientToken);
return req;
}
@@ -88,8 +88,7 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
QLOG_ERROR() << "Server didn't send a client token.";
return false;
}
- if (!getMojangAccount()->clientToken().isEmpty() &&
- clientToken != getMojangAccount()->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...
@@ -97,7 +96,7 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
<< "'. This shouldn't happen, but it isn't really a big deal.";
}
// Set the client token.
- getMojangAccount()->setClientToken(clientToken);
+ m_account->m_clientToken = clientToken;
// Now, we set the access token.
QLOG_DEBUG() << "Getting access token.";
@@ -109,7 +108,7 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
QLOG_ERROR() << "Server didn't send an access token.";
}
// Set the access token.
- getMojangAccount()->setAccessToken(accessToken);
+ m_account->m_accessToken = accessToken;
// Now we load the list of available profiles.
// Mojang hasn't yet implemented the profile system,
@@ -117,7 +116,7 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
// don't have trouble implementing it later.
QLOG_DEBUG() << "Loading profile list.";
QJsonArray availableProfiles = responseData.value("availableProfiles").toArray();
- ProfileList loadedProfiles;
+ QList<AccountProfile> loadedProfiles;
for (auto iter : availableProfiles)
{
QJsonObject profile = iter.toObject();
@@ -135,10 +134,10 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
}
// Now, add a new AccountProfile entry to the list.
- loadedProfiles.append(AccountProfile(id, name));
+ loadedProfiles.append({id, name});
}
// Put the list of profiles we loaded into the MojangAccount object.
- getMojangAccount()->loadProfiles(loadedProfiles);
+ m_account->m_profiles = loadedProfiles;
// Finally, we set the current profile to the correct value. This is pretty simple.
// We do need to make sure that the current profile that the server gave us
@@ -153,7 +152,7 @@ bool AuthenticateTask::processResponse(QJsonObject responseData)
QLOG_ERROR() << "Server didn't specify a currently selected profile.";
return false;
}
- if (!getMojangAccount()->setProfile(currentProfileId))
+ if (!m_account->setCurrentProfile(currentProfileId))
{
// TODO: Set an error to display to the user.
QLOG_ERROR() << "Server specified a selected profile that wasn't in the available "