mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-22 20:47:45 +00:00
Enable typing in the password first, then remembering the password later
This commit is contained in:
parent
4da74915c9
commit
13a5fda828
5 changed files with 34 additions and 8 deletions
|
@ -29,6 +29,7 @@ class Account : public QObject
|
||||||
Q_PROPERTY(bool useOTP READ useOTP WRITE setUseOTP NOTIFY useOTPChanged)
|
Q_PROPERTY(bool useOTP READ useOTP WRITE setUseOTP NOTIFY useOTPChanged)
|
||||||
Q_PROPERTY(GameLicense license READ license WRITE setLicense NOTIFY licenseChanged)
|
Q_PROPERTY(GameLicense license READ license WRITE setLicense NOTIFY licenseChanged)
|
||||||
Q_PROPERTY(bool isFreeTrial READ isFreeTrial WRITE setIsFreeTrial NOTIFY isFreeTrialChanged)
|
Q_PROPERTY(bool isFreeTrial READ isFreeTrial WRITE setIsFreeTrial NOTIFY isFreeTrialChanged)
|
||||||
|
Q_PROPERTY(bool needsPassword READ needsPassword NOTIFY needsPasswordChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Account(LauncherCore &launcher, const QString &key, QObject *parent = nullptr);
|
explicit Account(LauncherCore &launcher, const QString &key, QObject *parent = nullptr);
|
||||||
|
@ -82,6 +83,8 @@ public:
|
||||||
/// Updates FFXIV.cfg with some recommended options like turning the opening cutscene movie off
|
/// Updates FFXIV.cfg with some recommended options like turning the opening cutscene movie off
|
||||||
void updateConfig();
|
void updateConfig();
|
||||||
|
|
||||||
|
[[nodiscard]] bool needsPassword() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
void languageChanged();
|
void languageChanged();
|
||||||
|
@ -94,9 +97,11 @@ Q_SIGNALS:
|
||||||
void useOTPChanged();
|
void useOTPChanged();
|
||||||
void licenseChanged();
|
void licenseChanged();
|
||||||
void isFreeTrialChanged();
|
void isFreeTrialChanged();
|
||||||
|
bool needsPasswordChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fetchAvatar();
|
void fetchAvatar();
|
||||||
|
QCoro::Task<> fetchPassword();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets a value in the keychain. This function is asynchronous.
|
* Sets a value in the keychain. This function is asynchronous.
|
||||||
|
@ -112,4 +117,5 @@ private:
|
||||||
QString m_key;
|
QString m_key;
|
||||||
QString m_avatarUrl;
|
QString m_avatarUrl;
|
||||||
LauncherCore &m_launcher;
|
LauncherCore &m_launcher;
|
||||||
|
bool m_needsPassword = false;
|
||||||
};
|
};
|
|
@ -23,6 +23,7 @@ Account::Account(LauncherCore &launcher, const QString &key, QObject *parent)
|
||||||
, m_launcher(launcher)
|
, m_launcher(launcher)
|
||||||
{
|
{
|
||||||
fetchAvatar();
|
fetchAvatar();
|
||||||
|
fetchPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Account::uuid() const
|
QString Account::uuid() const
|
||||||
|
@ -184,6 +185,11 @@ QString Account::getPassword()
|
||||||
void Account::setPassword(const QString &password)
|
void Account::setPassword(const QString &password)
|
||||||
{
|
{
|
||||||
setKeychainValue(QStringLiteral("password"), password);
|
setKeychainValue(QStringLiteral("password"), password);
|
||||||
|
|
||||||
|
if (m_needsPassword) {
|
||||||
|
m_needsPassword = false;
|
||||||
|
Q_EMIT needsPasswordChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Account::getOTP()
|
QString Account::getOTP()
|
||||||
|
@ -327,4 +333,18 @@ void Account::updateConfig()
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Account::needsPassword() const
|
||||||
|
{
|
||||||
|
return m_needsPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
QCoro::Task<> Account::fetchPassword()
|
||||||
|
{
|
||||||
|
const QString password = co_await getKeychainValue(QStringLiteral("password"));
|
||||||
|
m_needsPassword = password.isEmpty();
|
||||||
|
Q_EMIT needsPasswordChanged();
|
||||||
|
|
||||||
|
co_return;
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_account.cpp"
|
#include "moc_account.cpp"
|
|
@ -210,7 +210,7 @@ bool LauncherCore::isSteam() const
|
||||||
bool LauncherCore::isSteamDeck() const
|
bool LauncherCore::isSteamDeck() const
|
||||||
{
|
{
|
||||||
if (m_steamApi != nullptr) {
|
if (m_steamApi != nullptr) {
|
||||||
return m_steamApi->isDeck() || qEnvironmentVariable("XDG_CURRENT_DESKTOP") == QStringLiteral("gamescope");
|
return m_steamApi->isDeck() || qEnvironmentVariable("SteamDeck") == QStringLiteral("1");
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qEnvironmentVariable("XDG_CURRENT_DESKTOP") == QStringLiteral("gamescope")) {
|
if (qEnvironmentVariable("SteamDeck") == QStringLiteral("1")) {
|
||||||
isSteamDeck = true;
|
isSteamDeck = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ QQC2.Control {
|
||||||
return i18n("Username is required.");
|
return i18n("Username is required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LauncherCore.currentProfile.account.rememberPassword && passwordField.text.length === 0) {
|
if (LauncherCore.currentProfile.account.needsPassword && passwordField.text.length === 0) {
|
||||||
return i18n("Password is required.");
|
return i18n("Password is required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ QQC2.Control {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LauncherCore.currentProfile.account.rememberPassword && passwordField.text.length === 0) {
|
if (LauncherCore.currentProfile.account.needsPassword && passwordField.text.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ QQC2.Control {
|
||||||
|
|
||||||
function updateFields() {
|
function updateFields() {
|
||||||
usernameField.text = LauncherCore.currentProfile.account.name;
|
usernameField.text = LauncherCore.currentProfile.account.name;
|
||||||
passwordField.text = LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : "";
|
passwordField.text = !LauncherCore.currentProfile.account.needsPassword && LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : "";
|
||||||
otpField.text = "";
|
otpField.text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ QQC2.Control {
|
||||||
function onAccountChanged() {
|
function onAccountChanged() {
|
||||||
page.updateFields();
|
page.updateFields();
|
||||||
|
|
||||||
if (!LauncherCore.currentProfile.account.rememberPassword) {
|
if (LauncherCore.currentProfile.account.needsPassword) {
|
||||||
passwordField.forceActiveFocus();
|
passwordField.forceActiveFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ QQC2.Control {
|
||||||
id: passwordField
|
id: passwordField
|
||||||
label: LauncherCore.currentProfile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password")
|
label: LauncherCore.currentProfile.account.isSapphire ? i18n("Password") : i18n("Square Enix Password")
|
||||||
echoMode: TextInput.Password
|
echoMode: TextInput.Password
|
||||||
enabled: !LauncherCore.currentProfile.account.rememberPassword
|
enabled: LauncherCore.currentProfile.account.needsPassword
|
||||||
focus: true
|
focus: true
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (otpField.visible) {
|
if (otpField.visible) {
|
||||||
|
@ -215,7 +215,7 @@ QQC2.Control {
|
||||||
loginButton.clicked();
|
loginButton.clicked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
text: LauncherCore.currentProfile.account.rememberPassword ? LauncherCore.currentProfile.account.getPassword() : ""
|
text: (!LauncherCore.currentProfile.account.needsPassword && LauncherCore.currentProfile.account.rememberPassword) ? LauncherCore.currentProfile.account.getPassword() : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
FormCard.FormDelegateSeparator {
|
FormCard.FormDelegateSeparator {
|
||||||
|
|
Loading…
Add table
Reference in a new issue