summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-30 00:19:27 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-30 00:19:27 +0100
commit035bdc7576fab3f1757af0e3bd77058bf44748c8 (patch)
tree22553231afde8ee05a36129190a41bcbf61e4a87
parent4ca6878743119647213ae02d9a9bb1a410768110 (diff)
downloadMultiMC-035bdc7576fab3f1757af0e3bd77058bf44748c8.tar
MultiMC-035bdc7576fab3f1757af0e3bd77058bf44748c8.tar.gz
MultiMC-035bdc7576fab3f1757af0e3bd77058bf44748c8.tar.lz
MultiMC-035bdc7576fab3f1757af0e3bd77058bf44748c8.tar.xz
MultiMC-035bdc7576fab3f1757af0e3bd77058bf44748c8.zip
GH-1524 Regenerate Minecraft client token when the auth token is invalid
This makes the case where users copy MultiMC to other machines easier to handle. It doesn't require manual intervention and the tokens do not go in a desync loop.
-rw-r--r--api/logic/minecraft/auth/MojangAccount.cpp6
-rw-r--r--api/logic/minecraft/auth/MojangAccount.h4
-rw-r--r--application/LaunchController.cpp1
3 files changed, 9 insertions, 2 deletions
diff --git a/api/logic/minecraft/auth/MojangAccount.cpp b/api/logic/minecraft/auth/MojangAccount.cpp
index 2b073aac..e6247608 100644
--- a/api/logic/minecraft/auth/MojangAccount.cpp
+++ b/api/logic/minecraft/auth/MojangAccount.cpp
@@ -298,3 +298,9 @@ void MojangAccount::incrementUses()
qWarning() << "Account" << m_username << "is now in use.";
}
}
+
+void MojangAccount::invalidateClientToken()
+{
+ m_clientToken = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
+ emit changed();
+}
diff --git a/api/logic/minecraft/auth/MojangAccount.h b/api/logic/minecraft/auth/MojangAccount.h
index 4902ec11..86d81c63 100644
--- a/api/logic/minecraft/auth/MojangAccount.h
+++ b/api/logic/minecraft/auth/MojangAccount.h
@@ -95,8 +95,8 @@ 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(AuthSessionPtr session,
- QString password = QString());
+ std::shared_ptr<YggdrasilTask> login(AuthSessionPtr session, QString password = QString());
+ void invalidateClientToken();
public: /* queries */
const QString &username() const
diff --git a/application/LaunchController.cpp b/application/LaunchController.cpp
index 62e582d8..e8f369be 100644
--- a/application/LaunchController.cpp
+++ b/application/LaunchController.cpp
@@ -108,6 +108,7 @@ void LaunchController::login()
auto failReasonNew = task->failReason();
if(failReasonNew == "Invalid token.")
{
+ account->invalidateClientToken();
failReason = needLoginAgain;
}
else failReason = failReasonNew;