1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00

Show login errors on auto login page

This commit is contained in:
Joshua Goins 2023-10-08 13:21:13 -04:00
parent a29609af4b
commit 043b42892e
3 changed files with 31 additions and 7 deletions

View file

@ -102,7 +102,7 @@ public:
* The launcher will still warn the user about any possible errors, however the call site will need to check the * The launcher will still warn the user about any possible errors, however the call site will need to check the
* result to see whether they need to "reset" or show a failed state or not. * result to see whether they need to "reset" or show a failed state or not.
*/ */
Q_INVOKABLE void autoLogin(Profile *profile); Q_INVOKABLE bool autoLogin(Profile *profile);
/* /*
* Launches the game using the provided authentication. * Launches the game using the provided authentication.

View file

@ -448,23 +448,24 @@ void LauncherCore::login(Profile *profile, const QString &username, const QStrin
beginLogin(*loginInformation); beginLogin(*loginInformation);
} }
void LauncherCore::autoLogin(Profile *profile) bool LauncherCore::autoLogin(Profile *profile)
{ {
QString otp; QString otp;
if (profile->account()->useOTP()) { if (profile->account()->useOTP()) {
if (!profile->account()->rememberOTP()) { if (!profile->account()->rememberOTP()) {
Q_EMIT loginError("This account does not have an OTP secret set, but requires it for login."); Q_EMIT loginError("This account does not have an OTP secret set, but requires it for login.");
return; return false;
} }
otp = profile->account()->getOTP(); otp = profile->account()->getOTP();
if (otp.isEmpty()) { if (otp.isEmpty()) {
Q_EMIT loginError("Failed to generate OTP, review the stored secret."); Q_EMIT loginError("Failed to generate OTP, review the stored secret.");
return; return false;
} }
} }
login(profile, profile->account()->name(), profile->account()->getPassword(), otp); login(profile, profile->account()->name(), profile->account()->getPassword(), otp);
return true;
} }
GameInstaller *LauncherCore::createInstaller(Profile *profile) GameInstaller *LauncherCore::createInstaller(Profile *profile)

View file

@ -13,7 +13,9 @@ Kirigami.Page {
title: i18n("Auto Login") title: i18n("Auto Login")
Kirigami.LoadingPlaceholder { globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None
Kirigami.PlaceholderMessage {
id: placeholderMessage id: placeholderMessage
anchors.centerIn: parent anchors.centerIn: parent
@ -38,8 +40,29 @@ Kirigami.Page {
running: true running: true
onTriggered: { onTriggered: {
autoLoginTimer.stop(); autoLoginTimer.stop();
LauncherCore.autoLogin(LauncherCore.autoLoginProfile); if (LauncherCore.autoLogin(LauncherCore.autoLoginProfile)) {
pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage")); pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage"));
}
}
}
Kirigami.PromptDialog {
id: errorDialog
title: i18n("Login Error")
showCloseButton: false
standardButtons: Kirigami.Dialog.Ok
onAccepted: applicationWindow().cancelAutoLogin()
onRejected: applicationWindow().cancelAutoLogin()
}
Connections {
target: LauncherCore
function onLoginError(message) {
errorDialog.subtitle = message
errorDialog.open()
} }
} }
} }