owncloudcmd: fetch the dav user
authorOlivier Goffart <ogoffart@woboq.com>
Wed, 24 Oct 2018 08:44:56 +0000 (10:44 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:15 +0000 (10:58 +0100)
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

src/cmd/cmd.cpp

index 3de2c43e3565ad16b08e3d4cbce60f0ffa0e53f2..62f719a78ea188c54e887fe03d2c6b8f8121362a 100644 (file)
@@ -466,13 +466,22 @@ int main(int argc, char **argv)
             loop.quit();
         });
         job->start();
-
         loop.exec();
 
         if (job->reply()->error() != QNetworkReply::NoError){
             std::cout<<"Error connecting to server\n";
             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