1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-06-08 06:57:46 +00:00

Add relevant buttons and inputs in settings window to accept otp secret

This commit is contained in:
Joshua Goins 2022-08-31 17:27:30 -04:00
parent d28ed71e87
commit 540c8b6f80
4 changed files with 35 additions and 1 deletions

View file

@ -91,6 +91,7 @@ public:
bool isSapphire = false;
QString lobbyURL;
bool rememberUsername = false, rememberPassword = false;
bool rememberOTPSecret = false;
bool useOneTimePassword = false;
bool autoLogin = false;

View file

@ -417,6 +417,7 @@ void LauncherCore::readInitialInformation() {
profile->lobbyURL = settings.value("lobbyURL", defaultSettings.lobbyURL).toString();
profile->rememberUsername = settings.value("rememberUsername", defaultSettings.rememberUsername).toBool();
profile->rememberPassword = settings.value("rememberPassword", defaultSettings.rememberPassword).toBool();
profile->rememberOTPSecret = settings.value("rememberOTPSecret", defaultSettings.rememberOTPSecret).toBool();
profile->useOneTimePassword = settings.value("useOneTimePassword", defaultSettings.useOneTimePassword).toBool();
profile->license = (GameLicense)settings.value("license", (int)defaultSettings.license).toInt();
profile->isFreeTrial = settings.value("isFreeTrial", defaultSettings.isFreeTrial).toBool();
@ -629,6 +630,7 @@ void LauncherCore::saveSettings() {
settings.setValue("lobbyURL", profile->lobbyURL);
settings.setValue("rememberUsername", profile->rememberUsername);
settings.setValue("rememberPassword", profile->rememberPassword);
settings.setValue("rememberOTPSecret", profile->rememberOTPSecret);
settings.setValue("useOneTimePassword", profile->useOneTimePassword);
settings.setValue("license", (int)profile->license);
settings.setValue("isFreeTrial", profile->isFreeTrial);

View file

@ -61,7 +61,8 @@ private:
QCheckBox* encryptArgumentsBox = nullptr;
QComboBox* serverType = nullptr;
QLineEdit* lobbyServerURL = nullptr;
QCheckBox *rememberUsernameBox = nullptr, *rememberPasswordBox = nullptr;
QCheckBox *rememberUsernameBox = nullptr, *rememberPasswordBox = nullptr, *rememberOTPSecretBox = nullptr;
QPushButton* otpSecretButton = nullptr;
QComboBox* gameLicenseBox = nullptr;
QCheckBox* freeTrialBox = nullptr;
QCheckBox* useOneTimePassword = nullptr;

View file

@ -6,11 +6,13 @@
#include <QFormLayout>
#include <QGridLayout>
#include <QGroupBox>
#include <QInputDialog>
#include <QLabel>
#include <QMessageBox>
#include <QProcess>
#include <QPushButton>
#include <QToolTip>
#include <keychain.h>
#include "gamescopesettingswindow.h"
#include "launchercore.h"
@ -257,6 +259,9 @@ void SettingsWindow::reloadControls() {
}
rememberUsernameBox->setChecked(profile.rememberUsername);
rememberPasswordBox->setChecked(profile.rememberPassword);
rememberOTPSecretBox->setChecked(profile.rememberOTPSecret);
rememberOTPSecretBox->setEnabled(profile.useOneTimePassword);
otpSecretButton->setEnabled(profile.rememberOTPSecret);
useOneTimePassword->setChecked(profile.useOneTimePassword);
useOneTimePassword->setEnabled(!profile.isSapphire);
if (!useOneTimePassword->isEnabled()) {
@ -419,6 +424,7 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
this->core.saveSettings();
});
rememberUsernameBox->setToolTip("Relatively harmless option, can save your password for later for convince.");
layout.addRow("Remember Username", rememberUsernameBox);
rememberPasswordBox = new QCheckBox();
@ -427,14 +433,38 @@ void SettingsWindow::setupLoginTab(QFormLayout& layout) {
this->core.saveSettings();
});
rememberPasswordBox->setToolTip("You should only save your password when using OTP and you're fairly confident your system can keep it's keychain secure.");
layout.addRow("Remember Password", rememberPasswordBox);
rememberOTPSecretBox = new QCheckBox();
connect(rememberOTPSecretBox, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().rememberOTPSecret = rememberOTPSecretBox->isChecked();
this->core.saveSettings();
this->reloadControls();
});
rememberOTPSecretBox->setToolTip("DANGEROUS! This should only be set if you're confident that your system keychain can securely store this. This trades convenience over the security an OTP can guarantee, so please be aware of that.");
layout.addRow("Remember OTP Secret", rememberOTPSecretBox);
otpSecretButton = new QPushButton("Enter OTP Secret");
connect(otpSecretButton, &QPushButton::pressed, [=] {
auto otpSecret = QInputDialog::getText(this, "OTP Input", "Enter your OTP Secret:");
auto job = new QKeychain::WritePasswordJob("SettingsWindow");
job->setTextData(otpSecret);
job->setKey(this->getCurrentProfile().name + "-otpsecret");
job->start();
});
otpSecretButton->setToolTip("Enter your OTP secret from Square Enix here. You cannot easily retrieve this if you forget it.");
layout.addRow(otpSecretButton);
useOneTimePassword = new QCheckBox();
connect(useOneTimePassword, &QCheckBox::stateChanged, [=](int) {
getCurrentProfile().useOneTimePassword = useOneTimePassword->isChecked();
this->core.saveSettings();
this->window.reloadControls();
this->reloadControls();
});
layout.addRow("Use One-Time Password", useOneTimePassword);