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.";
|
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.
|
* Attempt to login. Empty password means we use the token.
|
||||||
* If the attempt fails because we already are performing some task, it returns false.
|
* If the attempt fails because we already are performing some task, it returns false.
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<YggdrasilTask> login(AuthSessionPtr session,
|
std::shared_ptr<YggdrasilTask> login(AuthSessionPtr session, QString password = QString());
|
||||||
QString password = QString());
|
void invalidateClientToken();
|
||||||
|
|
||||||
public: /* queries */
|
public: /* queries */
|
||||||
const QString &username() const
|
const QString &username() const
|
||||||
|
@ -108,6 +108,7 @@ void LaunchController::login()
|
|||||||
auto failReasonNew = task->failReason();
|
auto failReasonNew = task->failReason();
|
||||||
if(failReasonNew == "Invalid token.")
|
if(failReasonNew == "Invalid token.")
|
||||||
{
|
{
|
||||||
|
account->invalidateClientToken();
|
||||||
failReason = needLoginAgain;
|
failReason = needLoginAgain;
|
||||||
}
|
}
|
||||||
else failReason = failReasonNew;
|
else failReason = failReasonNew;
|
||||||
|
Loading…
Reference in New Issue
Block a user