mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-04-29 22:24:26 +02:00
Always check Microsoft account for offline account
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
79180db663
commit
3840d8a37a
@ -220,13 +220,34 @@ void LaunchController::login()
|
|||||||
m_session->demo = m_demo;
|
m_session->demo = m_demo;
|
||||||
m_accountToUse->fillSession(m_session);
|
m_accountToUse->fillSession(m_session);
|
||||||
|
|
||||||
// Launch immediately in true offline mode
|
MinecraftAccountPtr accountToCheck;
|
||||||
if (m_accountToUse->accountType() == AccountType::Offline) {
|
|
||||||
launchInstance();
|
if (m_accountToUse->ownsMinecraft())
|
||||||
|
accountToCheck = m_accountToUse;
|
||||||
|
else if (const MinecraftAccountPtr defaultAccount = APPLICATION->accounts()->defaultAccount();
|
||||||
|
defaultAccount != nullptr && defaultAccount->ownsMinecraft()) {
|
||||||
|
accountToCheck = defaultAccount;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < APPLICATION->accounts()->count(); i++) {
|
||||||
|
MinecraftAccountPtr account = APPLICATION->accounts()->at(i);
|
||||||
|
if (account->ownsMinecraft())
|
||||||
|
accountToCheck = account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accountToCheck == nullptr) {
|
||||||
|
if (!m_session->demo)
|
||||||
|
m_session->demo = askPlayDemo();
|
||||||
|
|
||||||
|
if (m_session->demo)
|
||||||
|
launchInstance();
|
||||||
|
else
|
||||||
|
emitFailed(tr("Launch cancelled - account does not own Minecraft."));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m_accountToUse->accountState()) {
|
switch (accountToCheck->accountState()) {
|
||||||
case AccountState::Offline: {
|
case AccountState::Offline: {
|
||||||
m_session->wants_online = false;
|
m_session->wants_online = false;
|
||||||
}
|
}
|
||||||
@ -247,39 +268,25 @@ void LaunchController::login()
|
|||||||
}
|
}
|
||||||
m_session->MakeOffline(name);
|
m_session->MakeOffline(name);
|
||||||
// offline flavored game from here :3
|
// offline flavored game from here :3
|
||||||
}
|
} else if (m_accountToUse == accountToCheck && !m_accountToUse->hasProfile()) {
|
||||||
if (m_accountToUse->ownsMinecraft()) {
|
// Now handle setting up a profile name here...
|
||||||
if (!m_accountToUse->hasProfile()) {
|
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
||||||
// Now handle setting up a profile name here...
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
tryagain = true;
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
continue;
|
||||||
tryagain = true;
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
emitFailed(tr("Received undetermined session status during login."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// we own Minecraft, there is a profile, it's all ready to go!
|
|
||||||
launchInstance();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// play demo ?
|
|
||||||
if (!m_session->demo) {
|
|
||||||
m_session->demo = askPlayDemo();
|
|
||||||
}
|
|
||||||
if (m_session->demo) { // play demo here
|
|
||||||
launchInstance();
|
|
||||||
} else {
|
} else {
|
||||||
emitFailed(tr("Launch cancelled - account does not own Minecraft."));
|
emitFailed(tr("Received undetermined session status during login."));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we own Minecraft, there is a profile, it's all ready to go!
|
||||||
|
launchInstance();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case AccountState::Errored:
|
case AccountState::Errored:
|
||||||
// This means some sort of soft error that we can fix with a refresh ... so let's refresh.
|
// This means some sort of soft error that we can fix with a refresh ... so let's refresh.
|
||||||
case AccountState::Unchecked: {
|
case AccountState::Unchecked: {
|
||||||
m_accountToUse->refresh();
|
accountToCheck->refresh();
|
||||||
}
|
}
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case AccountState::Working: {
|
case AccountState::Working: {
|
||||||
@ -288,17 +295,18 @@ void LaunchController::login()
|
|||||||
if (m_online) {
|
if (m_online) {
|
||||||
progDialog.setSkipButton(true, tr("Play Offline"));
|
progDialog.setSkipButton(true, tr("Play Offline"));
|
||||||
}
|
}
|
||||||
auto task = m_accountToUse->currentTask();
|
auto task = accountToCheck->currentTask();
|
||||||
progDialog.execWithTask(task.get());
|
progDialog.execWithTask(task.get());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case AccountState::Expired: {
|
case AccountState::Expired: {
|
||||||
if (reauthenticateCurrentAccount())
|
if (reauthenticateAccount(accountToCheck))
|
||||||
continue;
|
continue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case AccountState::Disabled: {
|
case AccountState::Disabled: {
|
||||||
auto errorString = tr("The launcher's client identification has changed. Please remove this account and add it again.");
|
auto errorString = tr("The launcher's client identification has changed. Please remove '%1' and try again.");
|
||||||
|
|
||||||
QMessageBox::warning(m_parentWidget, tr("Client identification changed"), errorString, QMessageBox::StandardButton::Ok,
|
QMessageBox::warning(m_parentWidget, tr("Client identification changed"), errorString, QMessageBox::StandardButton::Ok,
|
||||||
QMessageBox::StandardButton::Ok);
|
QMessageBox::StandardButton::Ok);
|
||||||
emitFailed(errorString);
|
emitFailed(errorString);
|
||||||
@ -306,8 +314,9 @@ void LaunchController::login()
|
|||||||
}
|
}
|
||||||
case AccountState::Gone: {
|
case AccountState::Gone: {
|
||||||
auto errorString =
|
auto errorString =
|
||||||
tr("The account no longer exists on the servers. It may have been migrated, in which case please add the new account "
|
tr("'%1' no longer exists on the servers. It may have been migrated, in which case please add the new account "
|
||||||
"you migrated this one to.");
|
"you migrated this one to.")
|
||||||
|
.arg(accountToCheck->profileName());
|
||||||
QMessageBox::warning(m_parentWidget, tr("Account gone"), errorString, QMessageBox::StandardButton::Ok,
|
QMessageBox::warning(m_parentWidget, tr("Account gone"), errorString, QMessageBox::StandardButton::Ok,
|
||||||
QMessageBox::StandardButton::Ok);
|
QMessageBox::StandardButton::Ok);
|
||||||
emitFailed(errorString);
|
emitFailed(errorString);
|
||||||
@ -318,30 +327,35 @@ void LaunchController::login()
|
|||||||
emitFailed(tr("Failed to launch."));
|
emitFailed(tr("Failed to launch."));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LaunchController::reauthenticateCurrentAccount()
|
bool LaunchController::reauthenticateAccount(MinecraftAccountPtr account)
|
||||||
{
|
{
|
||||||
auto button =
|
auto button = QMessageBox::warning(
|
||||||
QMessageBox::warning(m_parentWidget, tr("Account refresh failed"),
|
m_parentWidget, tr("Account refresh failed"),
|
||||||
tr("The account has expired and needs to be reauthenticated. Do you want to reauthenticate this account?"),
|
tr("'%1' has expired and needs to be reauthenticated. Do you want to reauthenticate this account?").arg(account->profileName()),
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::Yes);
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::Yes);
|
||||||
if (button == QMessageBox::StandardButton::Yes) {
|
if (button == QMessageBox::StandardButton::Yes) {
|
||||||
auto accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
bool isDefault = accounts->defaultAccount() == m_accountToUse;
|
bool isDefault = accounts->defaultAccount() == account;
|
||||||
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(m_accountToUse->profileId())));
|
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(account->profileId())));
|
||||||
if (m_accountToUse->accountType() == AccountType::MSA) {
|
if (account->accountType() == AccountType::MSA) {
|
||||||
auto newAccount = MSALoginDialog::newAccount(m_parentWidget);
|
auto newAccount = MSALoginDialog::newAccount(m_parentWidget);
|
||||||
accounts->addAccount(newAccount);
|
|
||||||
if (isDefault) {
|
if (newAccount != nullptr) {
|
||||||
accounts->setDefaultAccount(newAccount);
|
accounts->addAccount(newAccount);
|
||||||
|
|
||||||
|
if (isDefault)
|
||||||
|
accounts->setDefaultAccount(newAccount);
|
||||||
|
|
||||||
|
if (m_accountToUse == account) {
|
||||||
|
m_accountToUse = nullptr;
|
||||||
|
decideAccount();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
m_accountToUse = nullptr;
|
|
||||||
decideAccount();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
emitFailed(tr("Account expired and re-login attempt failed"));
|
|
||||||
} else {
|
|
||||||
emitFailed(tr("The account has expired and needs to be reauthenticated"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitFailed(tr("The account has expired and needs to be reauthenticated"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class LaunchController : public Task {
|
|||||||
void decideAccount();
|
void decideAccount();
|
||||||
bool askPlayDemo();
|
bool askPlayDemo();
|
||||||
QString askOfflineName(QString playerName, bool demo, bool& ok);
|
QString askOfflineName(QString playerName, bool demo, bool& ok);
|
||||||
bool reauthenticateCurrentAccount();
|
bool reauthenticateAccount(MinecraftAccountPtr account);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readyForLaunch();
|
void readyForLaunch();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user