summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-12-27 22:56:43 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-12-27 22:56:54 +0100
commit391b1b32856a5964e429fd95ab588a5e9e745801 (patch)
tree2dd2e32746c5a0efa053418c1ad80645290c7550 /src/Cache.cpp
parentExpose appimage (diff)
downloadnheko-391b1b32856a5964e429fd95ab588a5e9e745801.tar.xz
Fix #359
Actually store the login details under the selected profile
Diffstat (limited to '')
-rw-r--r--src/Cache.cpp16
1 files changed, 8 insertions, 8 deletions
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<std::string> 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;