summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/settings/accountsettings.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-01-24 11:25:46 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-01-24 11:25:46 +0100
commitbf15c3977c27536e47578e8b0ecaedb852c5ff52 (patch)
tree55fc317d968fd7688a8961251c37fbdd059fbbfa /framework/src/domain/settings/accountsettings.cpp
parentf0d82e708e435f2d7f6d8e066481286bd023dff9 (diff)
downloadkube-bf15c3977c27536e47578e8b0ecaedb852c5ff52.tar.gz
kube-bf15c3977c27536e47578e8b0ecaedb852c5ff52.zip
Fixed initial account login.
Because we ended up trying to load the resources before they even existed (directly after the account was created), we ended up creating a second set of unconfigured resources. Storing the password by modifying the resource was an artifact of the past anyways, and a login function results in a cleaner system and fixes the problem at hand.
Diffstat (limited to 'framework/src/domain/settings/accountsettings.cpp')
-rw-r--r--framework/src/domain/settings/accountsettings.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/framework/src/domain/settings/accountsettings.cpp b/framework/src/domain/settings/accountsettings.cpp
index acf85522..a75d5e07 100644
--- a/framework/src/domain/settings/accountsettings.cpp
+++ b/framework/src/domain/settings/accountsettings.cpp
@@ -56,13 +56,10 @@ void AccountSettings::setAccountIdentifier(const QByteArray &id)
56 mName = QString(); 56 mName = QString();
57 mImapServer = QString(); 57 mImapServer = QString();
58 mImapUsername = QString(); 58 mImapUsername = QString();
59 mImapPassword = QString();
60 mSmtpServer = QString(); 59 mSmtpServer = QString();
61 mSmtpUsername = QString(); 60 mSmtpUsername = QString();
62 mSmtpPassword = QString();
63 mCardDavServer = QString(); 61 mCardDavServer = QString();
64 mCardDavUsername = QString(); 62 mCardDavUsername = QString();
65 mCardDavPassword = QString();
66 mPath = QString(); 63 mPath = QString();
67 emit changed(); 64 emit changed();
68 emit imapResourceChanged(); 65 emit imapResourceChanged();
@@ -292,9 +289,6 @@ void AccountSettings::saveImapResource()
292 {"server", mImapServer}, 289 {"server", mImapServer},
293 {"username", mImapUsername} 290 {"username", mImapUsername}
294 }); 291 });
295 if (!mImapPassword.isEmpty()) {
296 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mImapIdentifier, mImapPassword);
297 }
298} 292}
299 293
300void AccountSettings::saveCardDavResource() 294void AccountSettings::saveCardDavResource()
@@ -303,9 +297,6 @@ void AccountSettings::saveCardDavResource()
303 {"server", mCardDavServer}, 297 {"server", mCardDavServer},
304 {"username", mCardDavUsername} 298 {"username", mCardDavUsername}
305 }); 299 });
306 if (!mCardDavPassword.isEmpty()) {
307 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mCardDavIdentifier, mCardDavPassword);
308 }
309} 300}
310 301
311void AccountSettings::saveMaildirResource() 302void AccountSettings::saveMaildirResource()
@@ -321,9 +312,19 @@ void AccountSettings::saveMailtransportResource()
321 {"server", mSmtpServer}, 312 {"server", mSmtpServer},
322 {"username", mSmtpUsername} 313 {"username", mSmtpUsername}
323 }); 314 });
324 if (!mSmtpPassword.isEmpty()) { 315}
325 Kube::AccountKeyring{mAccountIdentifier}.storePassword(mMailtransportIdentifier, mSmtpPassword); 316
326 } 317void AccountSettings::login(const QVariantMap &secrets)
318{
319 auto accountSecret = secrets.value("accountSecret").toString();
320 Store::fetchAll<SinkResource>(Query().filter<SinkResource::Account>(mAccountIdentifier))
321 .then([=](const QList<SinkResource::Ptr> &resources) {
322 for (const auto &resource : resources) {
323 Kube::AccountKeyring{mAccountIdentifier}.storePassword(resource->identifier(), accountSecret);
324 }
325 }).onError([](const KAsync::Error &error) {
326 qWarning() << "Failed to load any account resources resource: " << error;
327 }).exec();
327} 328}
328 329
329void AccountSettings::saveIdentity() 330void AccountSettings::saveIdentity()