diff options
Diffstat (limited to 'lib/accountregistry.cpp')
-rw-r--r-- | lib/accountregistry.cpp | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/lib/accountregistry.cpp b/lib/accountregistry.cpp index 9b148b51..b40d5ecf 100644 --- a/lib/accountregistry.cpp +++ b/lib/accountregistry.cpp @@ -79,35 +79,45 @@ void AccountRegistry::invokeLogin() { const auto accounts = SettingsGroup("Accounts").childGroups(); for (const auto& accountId : accounts) { - AccountSettings account{accountId}; + AccountSettings account { accountId }; m_accountsLoading += accountId; emit accountsLoadingChanged(); - if (!account.homeserver().isEmpty()) { - auto accessTokenLoadingJob = loadAccessTokenFromKeychain(account.userId()); - connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, [accountId, this, accessTokenLoadingJob]() { - AccountSettings account{accountId}; - if (accessTokenLoadingJob->error() != QKeychain::Error::NoError) { - emit keychainError(accessTokenLoadingJob->error()); - return; - } - - auto connection = new Connection(account.homeserver()); - connect(connection, &Connection::connected, this, [connection] { - connection->loadState(); - connection->setLazyLoading(true); - - connection->syncLoop(); + if (account.homeserver().isEmpty()) + continue; + + auto accessTokenLoadingJob = + loadAccessTokenFromKeychain(account.userId()); + connect(accessTokenLoadingJob, &QKeychain::Job::finished, this, + [accountId, this, accessTokenLoadingJob]() { + if (accessTokenLoadingJob->error() + != QKeychain::Error::NoError) { + emit keychainError(accessTokenLoadingJob->error()); + return; + } + + AccountSettings account { accountId }; + auto connection = new Connection(account.homeserver()); + connect(connection, &Connection::connected, this, + [connection] { + connection->loadState(); + connection->setLazyLoading(true); + + connection->syncLoop(); + }); + connect(connection, &Connection::loginError, this, + [this, connection](const QString& error, + const QString& details) { + emit loginError(connection, error, details); + }); + connect(connection, &Connection::resolveError, this, + [this, connection](const QString& error) { + emit resolveError(connection, error); + }); + connection->assumeIdentity( + account.userId(), accessTokenLoadingJob->binaryData(), + account.deviceId()); }); - connect(connection, &Connection::loginError, this, [this, connection](const QString& error, const QString& details) { - emit loginError(connection, error, details); - }); - connect(connection, &Connection::resolveError, this, [this, connection](QString error) { - emit resolveError(connection, error); - }); - connection->assumeIdentity(account.userId(), accessTokenLoadingJob->binaryData(), account.deviceId()); - }); - } } } |