summaryrefslogtreecommitdiffstats
path: root/logic/auth/flows
diff options
context:
space:
mode:
Diffstat (limited to 'logic/auth/flows')
-rw-r--r--logic/auth/flows/AuthenticateTask.cpp23
-rw-r--r--logic/auth/flows/AuthenticateTask.h2
-rw-r--r--logic/auth/flows/RefreshTask.cpp18
-rw-r--r--logic/auth/flows/RefreshTask.h2
-rw-r--r--logic/auth/flows/ValidateTask.cpp4
-rw-r--r--logic/auth/flows/ValidateTask.h2
6 files changed, 23 insertions, 28 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 "
diff --git a/logic/auth/flows/AuthenticateTask.h b/logic/auth/flows/AuthenticateTask.h
index 3b99caad..b6564657 100644
--- a/logic/auth/flows/AuthenticateTask.h
+++ b/logic/auth/flows/AuthenticateTask.h
@@ -30,7 +30,7 @@ class AuthenticateTask : public YggdrasilTask
{
Q_OBJECT
public:
- AuthenticateTask(MojangAccountPtr account, const QString &password, QObject *parent = 0);
+ AuthenticateTask(MojangAccount *account, const QString &password, QObject *parent = 0);
protected:
virtual QJsonObject getRequestContent() const;
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;
}
diff --git a/logic/auth/flows/RefreshTask.h b/logic/auth/flows/RefreshTask.h
index 2596f6c7..2fd50c60 100644
--- a/logic/auth/flows/RefreshTask.h
+++ b/logic/auth/flows/RefreshTask.h
@@ -30,7 +30,7 @@ class RefreshTask : public YggdrasilTask
{
Q_OBJECT
public:
- RefreshTask(MojangAccountPtr account, QObject *parent = 0);
+ RefreshTask(MojangAccount * account, QObject *parent = 0);
protected:
virtual QJsonObject getRequestContent() const;
diff --git a/logic/auth/flows/ValidateTask.cpp b/logic/auth/flows/ValidateTask.cpp
index d9e0e46b..84d5e703 100644
--- a/logic/auth/flows/ValidateTask.cpp
+++ b/logic/auth/flows/ValidateTask.cpp
@@ -26,7 +26,7 @@
#include "logger/QsLog.h"
-ValidateTask::ValidateTask(MojangAccountPtr account, QObject *parent)
+ValidateTask::ValidateTask(MojangAccount * account, QObject *parent)
: YggdrasilTask(account, parent)
{
}
@@ -34,7 +34,7 @@ ValidateTask::ValidateTask(MojangAccountPtr account, QObject *parent)
QJsonObject ValidateTask::getRequestContent() const
{
QJsonObject req;
- req.insert("accessToken", getMojangAccount()->accessToken());
+ req.insert("accessToken", m_account->m_accessToken);
return req;
}
diff --git a/logic/auth/flows/ValidateTask.h b/logic/auth/flows/ValidateTask.h
index 3ff78c6a..9788f20b 100644
--- a/logic/auth/flows/ValidateTask.h
+++ b/logic/auth/flows/ValidateTask.h
@@ -28,7 +28,7 @@ class ValidateTask : public YggdrasilTask
{
Q_OBJECT
public:
- ValidateTask(MojangAccountPtr account, QObject *parent = 0);
+ ValidateTask(MojangAccount *account, QObject *parent = 0);
protected:
virtual QJsonObject getRequestContent() const;