Merge pull request #7426 from nextcloud/bugfix/accounts

Bugfix account removal
This commit is contained in:
Camila Ayres 2024-10-29 13:41:54 +01:00 коммит произвёл GitHub
Родитель d3cc3984a6 d080261692
Коммит eea2153727
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 16 добавлений и 10 удалений

Просмотреть файл

@ -393,13 +393,18 @@ void AccountManager::saveAccountHelper(Account *acc, QSettings &settings, bool s
const auto settingsMapKeys = acc->_settingsMap.keys(); const auto settingsMapKeys = acc->_settingsMap.keys();
for (const auto &key : settingsMapKeys) { for (const auto &key : settingsMapKeys) {
if (!acc->_settingsMap.value(key).isValid()) {
continue;
}
settings.setValue(key, acc->_settingsMap.value(key)); settings.setValue(key, acc->_settingsMap.value(key));
} }
settings.setValue(QLatin1String(authTypeC), acc->_credentials->authType()); settings.setValue(QLatin1String(authTypeC), acc->_credentials->authType());
// HACK: Save http_user also as user // HACK: Save http_user also as user
if (acc->_settingsMap.contains(httpUserC)) { const auto settingsMap = acc->_settingsMap;
settings.setValue(userC, acc->_settingsMap.value(httpUserC)); if (settingsMap.contains(httpUserC) && settingsMap.value(httpUserC).isValid()) {
settings.setValue(userC, settingsMap.value(httpUserC));
} }
} }

Просмотреть файл

@ -355,7 +355,7 @@ void WebFlowCredentials::forgetSensitiveData() {
_account->deleteAppPassword(); _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()) { if (kck.isEmpty()) {
qCDebug(lcWebFlowCredentials()) << "InvalidateToken: User is empty, bailing out!"; qCDebug(lcWebFlowCredentials()) << "InvalidateToken: User is empty, bailing out!";
return; return;

Просмотреть файл

@ -355,8 +355,8 @@ void OwncloudAdvancedSetupPage::stopSpinner()
QUrl OwncloudAdvancedSetupPage::serverUrl() const QUrl OwncloudAdvancedSetupPage::serverUrl() const
{ {
const QString urlString = dynamic_cast<OwncloudWizard *>(wizard())->ocUrl(); const auto urlString = dynamic_cast<OwncloudWizard *>(wizard())->ocUrl();
const QString user = dynamic_cast<OwncloudWizard *>(wizard())->getCredentials()->user(); const auto user = dynamic_cast<OwncloudWizard *>(wizard())->getCredentials()->user();
QUrl url(urlString); QUrl url(urlString);
url.setUserName(user); url.setUserName(user);

Просмотреть файл

@ -358,10 +358,9 @@ QUrl Account::deprecatedPrivateLinkUrl(const QByteArray &numericFileId) const
*/ */
void Account::clearCookieJar() void Account::clearCookieJar()
{ {
auto jar = qobject_cast<CookieJar *>(_am->cookieJar()); const auto jar = qobject_cast<CookieJar *>(_am->cookieJar());
ASSERT(jar); ASSERT(jar);
jar->setAllCookies(QList<QNetworkCookie>()); jar->setAllCookies(QList<QNetworkCookie>());
emit wantsAccountSaved(this);
} }
/*! This shares our official cookie jar (containing all the tasty /*! This shares our official cookie jar (containing all the tasty
@ -530,11 +529,12 @@ void Account::setUserVisibleHost(const QString &host)
QVariant Account::credentialSetting(const QString &key) const QVariant Account::credentialSetting(const QString &key) const
{ {
if (_credentials) { if (_credentials) {
QString prefix = _credentials->authType(); const auto prefix = _credentials->authType();
QVariant value = _settingsMap.value(prefix + "_" + key); auto value = _settingsMap.value(prefix + "_" + key);
if (value.isNull()) { if (value.isNull()) {
value = _settingsMap.value(key); value = _settingsMap.value(key);
} }
return value; return value;
} }
return QVariant(); return QVariant();
@ -829,9 +829,10 @@ void Account::writeAppPasswordOnce(QString appPassword){
} }
void Account::retrieveAppPassword(){ void Account::retrieveAppPassword(){
const QString key = credentials()->user() + app_password;
const QString kck = AbstractCredentials::keychainKey( const QString kck = AbstractCredentials::keychainKey(
url().toString(), url().toString(),
credentials()->user() + app_password, key,
id() id()
); );