diff --git a/launcher/core/include/launchercore.h b/launcher/core/include/launchercore.h index 4a1792b..57cd860 100755 --- a/launcher/core/include/launchercore.h +++ b/launcher/core/include/launchercore.h @@ -91,6 +91,7 @@ public: bool isSapphire = false; QString lobbyURL; bool rememberUsername = false, rememberPassword = false; + bool rememberOTPSecret = false; bool useOneTimePassword = false; bool autoLogin = false; diff --git a/launcher/core/src/launchercore.cpp b/launcher/core/src/launchercore.cpp index fb22f37..b1f9079 100755 --- a/launcher/core/src/launchercore.cpp +++ b/launcher/core/src/launchercore.cpp @@ -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); diff --git a/launcher/desktop/include/settingswindow.h b/launcher/desktop/include/settingswindow.h index d752257..5aa34e7 100644 --- a/launcher/desktop/include/settingswindow.h +++ b/launcher/desktop/include/settingswindow.h @@ -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; diff --git a/launcher/desktop/src/settingswindow.cpp b/launcher/desktop/src/settingswindow.cpp index b67ea7b..258d2f4 100644 --- a/launcher/desktop/src/settingswindow.cpp +++ b/launcher/desktop/src/settingswindow.cpp @@ -6,11 +6,13 @@ #include #include #include +#include #include #include #include #include #include +#include #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);