owncloudcmd: fetch the dav user

This is required to get the new endpoint working when the server
uses ldap or that the dav user is not the same as the login.

Issue #6830
This commit is contained in:
Olivier Goffart 2018-10-24 10:44:56 +02:00 committed by Kevin Ottens
parent ec8c02dad0
commit 3e4486c078
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2

View file

@ -466,13 +466,22 @@ int main(int argc, char **argv)
loop.quit(); loop.quit();
}); });
job->start(); job->start();
loop.exec(); loop.exec();
if (job->reply()->error() != QNetworkReply::NoError){ if (job->reply()->error() != QNetworkReply::NoError){
std::cout<<"Error connecting to server\n"; std::cout<<"Error connecting to server\n";
return EXIT_FAILURE; return EXIT_FAILURE;
} }
job = new JsonApiJob(account, QLatin1String("ocs/v1.php/cloud/user"));
QObject::connect(job, &JsonApiJob::jsonReceived, [&](const QJsonDocument &json) {
const QJsonObject data = json.object().value("ocs").toObject().value("data").toObject();
account->setDavUser(data.value("id").toString());
account->setDavDisplayName(data.value("display-name").toString());
loop.quit();
});
job->start();
loop.exec();
} }
// much lower age than the default since this utility is usually made to be run right after a change in the tests // much lower age than the default since this utility is usually made to be run right after a change in the tests