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.
This commit is contained in:
Petr Mrázek 2016-11-30 00:19:27 +01:00
parent 4ca6878743
commit 035bdc7576
3 changed files with 9 additions and 2 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -108,6 +108,7 @@ void LaunchController::login()
auto failReasonNew = task->failReason();
if(failReasonNew == "Invalid token.")
{
account->invalidateClientToken();
failReason = needLoginAgain;
}
else failReason = failReasonNew;