mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
1.8 Migration: Fix password overwrite #3539
This commit is contained in:
parent
7985c0d7f1
commit
aee20e0ed3
4 changed files with 14 additions and 8 deletions
|
@ -119,21 +119,27 @@ bool AccountManager::restoreFromLegacySettings()
|
|||
return false;
|
||||
}
|
||||
|
||||
void AccountManager::save()
|
||||
void AccountManager::save(bool saveCredentials)
|
||||
{
|
||||
auto settings = Account::settingsWithGroup(QLatin1String(accountsC));
|
||||
foreach (const auto &acc, _accounts) {
|
||||
settings->beginGroup(acc->account()->id());
|
||||
save(acc->account(), *settings);
|
||||
save(acc->account(), *settings, saveCredentials);
|
||||
settings->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void AccountManager::save(const AccountPtr& acc, QSettings& settings)
|
||||
void AccountManager::save(const AccountPtr& acc, QSettings& settings, bool saveCredentials)
|
||||
{
|
||||
settings.setValue(QLatin1String(urlC), acc->_url.toString());
|
||||
if (acc->_credentials) {
|
||||
if (saveCredentials) {
|
||||
// Only persist the credentials if the parameter is set, on migration from 1.8.x
|
||||
// we want to save the accounts but not overwrite the credentials
|
||||
// (This is easier than asynchronously fetching the credentials from keychain and then
|
||||
// re-persisting them)
|
||||
acc->_credentials->persist();
|
||||
}
|
||||
Q_FOREACH(QString key, acc->_settingsMap.keys()) {
|
||||
settings.setValue(key, acc->_settingsMap.value(key));
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
/**
|
||||
* Saves the accounts to a given settings file
|
||||
*/
|
||||
void save();
|
||||
void save(bool saveCredentials = true);
|
||||
|
||||
/**
|
||||
* Creates account objects from from a given settings file.
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
static AccountPtr createAccount();
|
||||
|
||||
private:
|
||||
void save(const AccountPtr& account, QSettings& settings);
|
||||
void save(const AccountPtr& account, QSettings& settings, bool saveCredentials = true);
|
||||
AccountPtr load(QSettings& settings);
|
||||
bool restoreFromLegacySettings();
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ int FolderMan::setupFolders()
|
|||
if (accountsWithSettings.isEmpty()) {
|
||||
int r = setupFoldersMigration();
|
||||
if (r > 0) {
|
||||
AccountManager::instance()->save();
|
||||
AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
#include "accountmanager.h"
|
||||
OCC::AccountManager *OCC::AccountManager::instance() { return 0; }
|
||||
|
||||
void OCC::AccountManager::save() { }
|
||||
void OCC::AccountManager::save(bool saveCredentials) { Q_UNUSED(saveCredentials); }
|
||||
|
|
Loading…
Reference in a new issue