From 391b1b32856a5964e429fd95ab588a5e9e745801 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 27 Dec 2020 22:56:43 +0100 Subject: Fix #359 Actually store the login details under the selected profile --- src/Cache.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/Cache.cpp') diff --git a/src/Cache.cpp b/src/Cache.cpp index 7efae881..dac0b23a 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -167,14 +167,14 @@ Cache::Cache(const QString &userId, QObject *parent) void Cache::setup() { - UserSettings settings; + auto settings = UserSettings::instance(); nhlog::db()->debug("setting up cache"); cacheDirectory_ = QString("%1/%2%3") .arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation)) .arg(QString::fromUtf8(localUserId_.toUtf8().toHex())) - .arg(QString::fromUtf8(settings.profile().toUtf8().toHex())); + .arg(QString::fromUtf8(settings->profile().toUtf8().toHex())); bool isInitial = !QFile::exists(cacheDirectory_); @@ -578,12 +578,12 @@ Cache::restoreOlmAccount() void Cache::storeSecret(const std::string &name, const std::string &secret) { - UserSettings settings; + auto settings = UserSettings::instance(); QKeychain::WritePasswordJob job(QCoreApplication::applicationName()); job.setAutoDelete(false); job.setInsecureFallback(true); job.setKey("matrix." + - QString(QCryptographicHash::hash(settings.profile().toUtf8(), + QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)) + "." + name.c_str()); job.setTextData(QString::fromStdString(secret)); @@ -603,12 +603,12 @@ Cache::storeSecret(const std::string &name, const std::string &secret) void Cache::deleteSecret(const std::string &name) { - UserSettings settings; + auto settings = UserSettings::instance(); QKeychain::DeletePasswordJob job(QCoreApplication::applicationName()); job.setAutoDelete(false); job.setInsecureFallback(true); job.setKey("matrix." + - QString(QCryptographicHash::hash(settings.profile().toUtf8(), + QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)) + "." + name.c_str()); QEventLoop loop; @@ -622,12 +622,12 @@ Cache::deleteSecret(const std::string &name) std::optional Cache::secret(const std::string &name) { - UserSettings settings; + auto settings = UserSettings::instance(); QKeychain::ReadPasswordJob job(QCoreApplication::applicationName()); job.setAutoDelete(false); job.setInsecureFallback(true); job.setKey("matrix." + - QString(QCryptographicHash::hash(settings.profile().toUtf8(), + QString(QCryptographicHash::hash(settings->profile().toUtf8(), QCryptographicHash::Sha256)) + "." + name.c_str()); QEventLoop loop; -- cgit 1.5.1