mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-20 11:47:46 +00:00
Show login errors on auto login page
This commit is contained in:
parent
a29609af4b
commit
043b42892e
3 changed files with 31 additions and 7 deletions
|
@ -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
|
||||
* 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.
|
||||
|
|
|
@ -448,23 +448,24 @@ void LauncherCore::login(Profile *profile, const QString &username, const QStrin
|
|||
beginLogin(*loginInformation);
|
||||
}
|
||||
|
||||
void LauncherCore::autoLogin(Profile *profile)
|
||||
bool LauncherCore::autoLogin(Profile *profile)
|
||||
{
|
||||
QString otp;
|
||||
if (profile->account()->useOTP()) {
|
||||
if (!profile->account()->rememberOTP()) {
|
||||
Q_EMIT loginError("This account does not have an OTP secret set, but requires it for login.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
otp = profile->account()->getOTP();
|
||||
if (otp.isEmpty()) {
|
||||
Q_EMIT loginError("Failed to generate OTP, review the stored secret.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
login(profile, profile->account()->name(), profile->account()->getPassword(), otp);
|
||||
return true;
|
||||
}
|
||||
|
||||
GameInstaller *LauncherCore::createInstaller(Profile *profile)
|
||||
|
|
|
@ -13,7 +13,9 @@ Kirigami.Page {
|
|||
|
||||
title: i18n("Auto Login")
|
||||
|
||||
Kirigami.LoadingPlaceholder {
|
||||
globalToolBarStyle: Kirigami.ApplicationHeaderStyle.None
|
||||
|
||||
Kirigami.PlaceholderMessage {
|
||||
id: placeholderMessage
|
||||
|
||||
anchors.centerIn: parent
|
||||
|
@ -38,8 +40,29 @@ Kirigami.Page {
|
|||
running: true
|
||||
onTriggered: {
|
||||
autoLoginTimer.stop();
|
||||
LauncherCore.autoLogin(LauncherCore.autoLoginProfile);
|
||||
pageStack.layers.push(Qt.createComponent("zone.xiv.astra", "StatusPage"));
|
||||
if (LauncherCore.autoLogin(LauncherCore.autoLoginProfile)) {
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue