mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-09-03 21:49:13 +00:00
GH-4978 Add button to log back in when account expired
This commit is contained in:
parent
e044744faf
commit
0fd546a11c
@ -9,6 +9,8 @@
|
|||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
#include "ui/dialogs/EditAccountDialog.h"
|
#include "ui/dialogs/EditAccountDialog.h"
|
||||||
#include "ui/dialogs/ProfileSetupDialog.h"
|
#include "ui/dialogs/ProfileSetupDialog.h"
|
||||||
|
#include "ui/dialogs/LoginDialog.h"
|
||||||
|
#include "ui/dialogs/MSALoginDialog.h"
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
@ -119,7 +121,8 @@ void LaunchController::login() {
|
|||||||
m_session->wants_online = m_online;
|
m_session->wants_online = m_online;
|
||||||
m_accountToUse->fillSession(m_session);
|
m_accountToUse->fillSession(m_session);
|
||||||
|
|
||||||
switch(m_accountToUse->accountState()) {
|
//switch(m_accountToUse->accountState()) {
|
||||||
|
switch (AccountState::Expired) {
|
||||||
case AccountState::Offline: {
|
case AccountState::Offline: {
|
||||||
m_session->wants_online = false;
|
m_session->wants_online = false;
|
||||||
// NOTE: fallthrough is intentional
|
// NOTE: fallthrough is intentional
|
||||||
@ -223,16 +226,57 @@ void LaunchController::login() {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
case AccountState::Expired: {
|
case AccountState::Expired: {
|
||||||
auto errorString = tr("The account has expired and needs to be logged into manually again.");
|
auto errorString = tr("The account has expired and needs to be logged into manually. Press OK to log in again.");
|
||||||
QMessageBox::warning(
|
auto button = QMessageBox::warning(
|
||||||
m_parentWidget,
|
m_parentWidget,
|
||||||
tr("Account refresh failed"),
|
tr("Account refresh failed"),
|
||||||
errorString,
|
errorString,
|
||||||
QMessageBox::StandardButton::Ok,
|
QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel,
|
||||||
QMessageBox::StandardButton::Ok
|
QMessageBox::StandardButton::Ok
|
||||||
);
|
);
|
||||||
emitFailed(errorString);
|
if (button == QMessageBox::StandardButton::Ok) {
|
||||||
return;
|
auto accounts = APPLICATION->accounts();
|
||||||
|
bool isDefault = accounts->defaultAccount() == m_accountToUse;
|
||||||
|
bool msa = m_accountToUse->isMSA();
|
||||||
|
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(m_accountToUse->profileId())));
|
||||||
|
MinecraftAccountPtr newAccount = nullptr;
|
||||||
|
if (msa) {
|
||||||
|
if(BuildConfig.BUILD_PLATFORM == "osx64") {
|
||||||
|
CustomMessageBox::selectable(
|
||||||
|
m_parentWidget,
|
||||||
|
tr("Microsoft Accounts not available"),
|
||||||
|
tr(
|
||||||
|
"Microsoft accounts are only usable on macOS 10.13 or newer, with fully updated MultiMC.\n\n"
|
||||||
|
"Please update both your operating system and MultiMC."
|
||||||
|
),
|
||||||
|
QMessageBox::Warning
|
||||||
|
)->exec();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newAccount = MSALoginDialog::newAccount(
|
||||||
|
m_parentWidget,
|
||||||
|
tr("Please enter your Mojang account email and password to add your account.")
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
newAccount = LoginDialog::newAccount(
|
||||||
|
m_parentWidget,
|
||||||
|
tr("Please enter your Mojang account email and password to add your account.")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (newAccount) {
|
||||||
|
accounts->addAccount(newAccount);
|
||||||
|
if (isDefault) {
|
||||||
|
accounts->setDefaultAccount(newAccount);
|
||||||
|
}
|
||||||
|
m_accountToUse = newAccount;
|
||||||
|
} else {
|
||||||
|
emitFailed(tr("Account expired and re-login attempt failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
emitFailed(errorString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case AccountState::Gone: {
|
case AccountState::Gone: {
|
||||||
auto errorString = tr("The account no longer exists on the servers. It may have been migrated, in which case please add the new account you migrated this one to.");
|
auto errorString = tr("The account no longer exists on the servers. It may have been migrated, in which case please add the new account you migrated this one to.");
|
||||||
|
Loading…
Reference in New Issue
Block a user