mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Merge pull request #3727 from nextcloud/bugfix/only-set-dav-user-after-login
Only set dav user after login
This commit is contained in:
commit
c07aec320a
2 changed files with 23 additions and 26 deletions
|
@ -323,12 +323,29 @@ void OwncloudSetupWizard::slotConnectToOCUrl(const QString &url)
|
|||
qCInfo(lcWizard) << "Connect to url: " << url;
|
||||
AbstractCredentials *creds = _ocWizard->getCredentials();
|
||||
_ocWizard->account()->setCredentials(creds);
|
||||
_ocWizard->setField(QLatin1String("OCUrl"), url);
|
||||
_ocWizard->appendToConfigurationLog(tr("Trying to connect to %1 at %2 …")
|
||||
.arg(Theme::instance()->appNameGUI())
|
||||
.arg(url));
|
||||
|
||||
testOwnCloudConnect();
|
||||
const auto fetchUserNameJob = new JsonApiJob(_ocWizard->account()->sharedFromThis(), QStringLiteral("/ocs/v1.php/cloud/user"));
|
||||
connect(fetchUserNameJob, &JsonApiJob::jsonReceived, this, [this, url](const QJsonDocument &json, int statusCode) {
|
||||
if (statusCode != 100) {
|
||||
qCWarning(lcWizard) << "Could not fetch username.";
|
||||
}
|
||||
|
||||
sender()->deleteLater();
|
||||
|
||||
const auto objData = json.object().value("ocs").toObject().value("data").toObject();
|
||||
const auto userId = objData.value("id").toString("");
|
||||
const auto displayName = objData.value("display-name").toString("");
|
||||
_ocWizard->account()->setDavUser(userId);
|
||||
_ocWizard->account()->setDavDisplayName(displayName);
|
||||
|
||||
_ocWizard->setField(QLatin1String("OCUrl"), url);
|
||||
_ocWizard->appendToConfigurationLog(tr("Trying to connect to %1 at %2 …")
|
||||
.arg(Theme::instance()->appNameGUI())
|
||||
.arg(url));
|
||||
|
||||
testOwnCloudConnect();
|
||||
});
|
||||
fetchUserNameJob->start();
|
||||
}
|
||||
|
||||
void OwncloudSetupWizard::testOwnCloudConnect()
|
||||
|
|
|
@ -108,27 +108,7 @@ void Flow2AuthWidget::slotAuthResult(Flow2Auth::Result r, const QString &errorSt
|
|||
}
|
||||
}
|
||||
|
||||
_account->setCredentials(new WebFlowCredentials(user, appPassword));
|
||||
const auto fetchUserNameJob = new JsonApiJob(_account->sharedFromThis(), QStringLiteral("/ocs/v1.php/cloud/user"));
|
||||
connect(fetchUserNameJob, &JsonApiJob::jsonReceived, this, [this, fetchUserNameJob, r, errorString, user, appPassword](const QJsonDocument &json, int statusCode) {
|
||||
fetchUserNameJob->deleteLater();
|
||||
if (statusCode != 100) {
|
||||
qCWarning(lcFlow2AuthWidget) << "Could not fetch username.";
|
||||
_account->setDavUser("");
|
||||
_account->setDavDisplayName(user);
|
||||
emit authResult(r, errorString, user, appPassword);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto objData = json.object().value("ocs").toObject().value("data").toObject();
|
||||
const auto userId = objData.value("id").toString(user);
|
||||
const auto displayName = objData.value("display-name").toString();
|
||||
_account->setDavUser(userId);
|
||||
_account->setDavDisplayName(displayName);
|
||||
|
||||
emit authResult(r, errorString, user, appPassword);
|
||||
});
|
||||
fetchUserNameJob->start();
|
||||
emit authResult(r, errorString, user, appPassword);
|
||||
}
|
||||
|
||||
void Flow2AuthWidget::setError(const QString &error) {
|
||||
|
|
Loading…
Reference in a new issue