From d038ae84829de6ee452612670a6545cd3c9285fb Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 28 Oct 2024 18:37:15 +0100 Subject: [PATCH 1/3] Remove call to wantsAccountSaved when clearing the cookies. The cookies are cleared when an account is removed, this call was bringing back the deleted account. Signed-off-by: Camila Ayres --- src/libsync/account.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 401e22ae9..16a5263c2 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -361,7 +361,6 @@ void Account::clearCookieJar() auto jar = qobject_cast(_am->cookieJar()); ASSERT(jar); jar->setAllCookies(QList()); - emit wantsAccountSaved(this); } /*! This shares our official cookie jar (containing all the tasty From 33cc5a2017b0bea38b43af6d0d60fe014658d8a9 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 28 Oct 2024 20:07:28 +0100 Subject: [PATCH 2/3] Validate http_user value before assigning it to user in the config file. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 57dfd097b..8cb16779c 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -393,12 +393,16 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s const auto settingsMapKeys = acc->_settingsMap.keys(); for (const auto &key : settingsMapKeys) { + if (!acc->_settingsMap.value(key).isValid()) { + continue; + } + settings.setValue(key, acc->_settingsMap.value(key)); } settings.setValue(QLatin1String(authTypeC), acc->_credentials->authType()); // HACK: Save http_user also as user - if (acc->_settingsMap.contains(httpUserC)) { + if (acc->_settingsMap.contains(httpUserC) && acc->_settingsMap.value(httpUserC).isValid()) { settings.setValue(userC, acc->_settingsMap.value(httpUserC)); } } From d0802616923cdd743cb0f38f335c5ab028431ffe Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 28 Oct 2024 20:27:53 +0100 Subject: [PATCH 3/3] Use const auto. Signed-off-by: Camila Ayres --- src/gui/accountmanager.cpp | 5 +++-- src/gui/creds/webflowcredentials.cpp | 2 +- src/gui/wizard/owncloudadvancedsetuppage.cpp | 4 ++-- src/libsync/account.cpp | 10 ++++++---- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 8cb16779c..c6102a7d7 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -402,8 +402,9 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s settings.setValue(QLatin1String(authTypeC), acc->_credentials->authType()); // HACK: Save http_user also as user - if (acc->_settingsMap.contains(httpUserC) && acc->_settingsMap.value(httpUserC).isValid()) { - settings.setValue(userC, acc->_settingsMap.value(httpUserC)); + const auto settingsMap = acc->_settingsMap; + if (settingsMap.contains(httpUserC) && settingsMap.value(httpUserC).isValid()) { + settings.setValue(userC, settingsMap.value(httpUserC)); } } diff --git a/src/gui/creds/webflowcredentials.cpp b/src/gui/creds/webflowcredentials.cpp index 072753cac..0495d3b88 100644 --- a/src/gui/creds/webflowcredentials.cpp +++ b/src/gui/creds/webflowcredentials.cpp @@ -355,7 +355,7 @@ void WebFlowCredentials::forgetSensitiveData() { _account->deleteAppPassword(); - const QString kck = keychainKey(_account->url().toString(), _user, _account->id()); + const auto kck = keychainKey(_account->url().toString(), _user, _account->id()); if (kck.isEmpty()) { qCDebug(lcWebFlowCredentials()) << "InvalidateToken: User is empty, bailing out!"; return; diff --git a/src/gui/wizard/owncloudadvancedsetuppage.cpp b/src/gui/wizard/owncloudadvancedsetuppage.cpp index f242db0d3..080170981 100644 --- a/src/gui/wizard/owncloudadvancedsetuppage.cpp +++ b/src/gui/wizard/owncloudadvancedsetuppage.cpp @@ -355,8 +355,8 @@ void OwncloudAdvancedSetupPage::stopSpinner() QUrl OwncloudAdvancedSetupPage::serverUrl() const { - const QString urlString = dynamic_cast(wizard())->ocUrl(); - const QString user = dynamic_cast(wizard())->getCredentials()->user(); + const auto urlString = dynamic_cast(wizard())->ocUrl(); + const auto user = dynamic_cast(wizard())->getCredentials()->user(); QUrl url(urlString); url.setUserName(user); diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 16a5263c2..7f9d93c93 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -358,7 +358,7 @@ QUrl Account::deprecatedPrivateLinkUrl(const QByteArray &numericFileId) const */ void Account::clearCookieJar() { - auto jar = qobject_cast(_am->cookieJar()); + const auto jar = qobject_cast(_am->cookieJar()); ASSERT(jar); jar->setAllCookies(QList()); } @@ -529,11 +529,12 @@ void Account::setUserVisibleHost(const QString &host) QVariant Account::credentialSetting(const QString &key) const { if (_credentials) { - QString prefix = _credentials->authType(); - QVariant value = _settingsMap.value(prefix + "_" + key); + const auto prefix = _credentials->authType(); + auto value = _settingsMap.value(prefix + "_" + key); if (value.isNull()) { value = _settingsMap.value(key); } + return value; } return QVariant(); @@ -828,9 +829,10 @@ void Account::writeAppPasswordOnce(QString appPassword){ } void Account::retrieveAppPassword(){ + const QString key = credentials()->user() + app_password; const QString kck = AbstractCredentials::keychainKey( url().toString(), - credentials()->user() + app_password, + key, id() );