summaryrefslogtreecommitdiffstats
path: root/logic/auth/MojangAccount.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-01-27 03:00:49 +0100
committerPetr Mrázek <peterix@gmail.com>2014-01-27 03:00:49 +0100
commitffbc5bb62c0cd771b26cb1d9b5afdccef77075b4 (patch)
tree78b10cee3dc25acba02954aaf4f0e44ee4c295de /logic/auth/MojangAccount.h
parentd7113de3bd3cb43b1bc68792cd27a716b012f2b5 (diff)
downloadMultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar.gz
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar.lz
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.tar.xz
MultiMC-ffbc5bb62c0cd771b26cb1d9b5afdccef77075b4.zip
Offline mode can be used even when online.
Allow the user to pick a player name for offline mode. Big auth refactor. Now using session objects instead of the accounts themselves. Sessions only last for one instance start and hold all the auth and player data.
Diffstat (limited to 'logic/auth/MojangAccount.h')
-rw-r--r--logic/auth/MojangAccount.h38
1 files changed, 11 insertions, 27 deletions
diff --git a/logic/auth/MojangAccount.h b/logic/auth/MojangAccount.h
index dd5d54ae..a0565e2c 100644
--- a/logic/auth/MojangAccount.h
+++ b/logic/auth/MojangAccount.h
@@ -23,6 +23,7 @@
#include <QMap>
#include <memory>
+#include "AuthSession.h"
class Task;
class YggdrasilTask;
@@ -45,17 +46,10 @@ struct AccountProfile
bool legacy;
};
-struct User
-{
- QString id;
- QMultiMap<QString,QString> properties;
-};
-
enum AccountStatus
{
NotVerified,
- Verified,
- Online
+ Verified
};
/**
@@ -84,7 +78,7 @@ public: /* construction */
QJsonObject saveToJson() const;
public: /* manipulation */
- /**
+ /**
* Sets the currently selected profile to the profile with the given ID string.
* If profileId is not in the list of available profiles, the function will simply return
* false.
@@ -95,12 +89,9 @@ public: /* manipulation */
* Attempt to login. Empty password means we use the token.
* If the attempt fails because we already are performing some task, it returns false.
*/
- std::shared_ptr<YggdrasilTask> login(QString password = QString());
+ std::shared_ptr<YggdrasilTask> login(AuthSessionPtr session,
+ QString password = QString());
- void downgrade()
- {
- m_online = false;
- }
public: /* queries */
const QString &username() const
{
@@ -122,19 +113,11 @@ public: /* queries */
return m_profiles;
}
- const User & user()
+ const User &user()
{
return m_user;
}
- //! Get the session ID required for legacy Minecraft versions
- QString sessionId() const
- {
- if (m_currentProfile != -1 && !m_accessToken.isEmpty())
- return "token:" + m_accessToken + ":" + m_profiles[m_currentProfile].id;
- return "-";
- }
-
//! Returns the currently selected profile (if none, returns nullptr)
const AccountProfile *currentProfile() const;
@@ -169,16 +152,17 @@ protected: /* variables */
// the user structure, whatever it is.
User m_user;
- // true when the account is verified
- bool m_online = false;
-
// current task we are executing here
std::shared_ptr<YggdrasilTask> m_currentTask;
-private slots:
+private
+slots:
void authSucceeded();
void authFailed(QString reason);
+private:
+ void fillSession(AuthSessionPtr session);
+
public:
friend class YggdrasilTask;
friend class AuthenticateTask;