mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-02 15:44:28 +02:00
Merge pull request #1953 from Trial97/account2
Auto reauthenticate account if expired
This commit is contained in:
commit
e7ff3146fe
@ -43,6 +43,7 @@
|
|||||||
#include "ui/InstanceWindow.h"
|
#include "ui/InstanceWindow.h"
|
||||||
#include "ui/MainWindow.h"
|
#include "ui/MainWindow.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
#include "ui/dialogs/MSALoginDialog.h"
|
||||||
#include "ui/dialogs/ProfileSelectDialog.h"
|
#include "ui/dialogs/ProfileSelectDialog.h"
|
||||||
#include "ui/dialogs/ProfileSetupDialog.h"
|
#include "ui/dialogs/ProfileSetupDialog.h"
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
@ -287,10 +288,8 @@ void LaunchController::login()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case AccountState::Expired: {
|
case AccountState::Expired: {
|
||||||
auto errorString = tr("The account has expired and needs to be logged into manually again.");
|
if (reauthenticateCurrentAccount())
|
||||||
QMessageBox::warning(m_parentWidget, tr("Account refresh failed"), errorString, QMessageBox::StandardButton::Ok,
|
continue;
|
||||||
QMessageBox::StandardButton::Ok);
|
|
||||||
emitFailed(errorString);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case AccountState::Disabled: {
|
case AccountState::Disabled: {
|
||||||
@ -314,6 +313,33 @@ void LaunchController::login()
|
|||||||
emitFailed(tr("Failed to launch."));
|
emitFailed(tr("Failed to launch."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LaunchController::reauthenticateCurrentAccount()
|
||||||
|
{
|
||||||
|
auto button =
|
||||||
|
QMessageBox::warning(m_parentWidget, tr("Account refresh failed"),
|
||||||
|
tr("The account has expired and needs to be reauthenticated. Do you want to reauthenticate this account?"),
|
||||||
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::Yes);
|
||||||
|
if (button == QMessageBox::StandardButton::Yes) {
|
||||||
|
auto accounts = APPLICATION->accounts();
|
||||||
|
bool isDefault = accounts->defaultAccount() == m_accountToUse;
|
||||||
|
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(m_accountToUse->profileId())));
|
||||||
|
if (m_accountToUse->accountType() == AccountType::MSA) {
|
||||||
|
auto newAccount = MSALoginDialog::newAccount(m_parentWidget);
|
||||||
|
accounts->addAccount(newAccount);
|
||||||
|
if (isDefault) {
|
||||||
|
accounts->setDefaultAccount(newAccount);
|
||||||
|
}
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void LaunchController::launchInstance()
|
void LaunchController::launchInstance()
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL");
|
Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL");
|
||||||
|
@ -76,6 +76,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();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readyForLaunch();
|
void readyForLaunch();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user