mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-27 03:14:49 +00:00
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:
parent
4ca6878743
commit
035bdc7576
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -108,6 +108,7 @@ void LaunchController::login()
|
||||
auto failReasonNew = task->failReason();
|
||||
if(failReasonNew == "Invalid token.")
|
||||
{
|
||||
account->invalidateClientToken();
|
||||
failReason = needLoginAgain;
|
||||
}
|
||||
else failReason = failReasonNew;
|
||||
|
Loading…
Reference in New Issue
Block a user