owncloudcmd: fix compiliation with TOKEN_AUTH_ONLY
authorGerhard Gappmeier <gerhard.gappmeier@ascolab.com>
Fri, 9 Nov 2018 12:39:50 +0000 (13:39 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:18 +0000 (10:58 +0100)
src/cmd/cmd.cpp

index 9ea2546bc43c6fcbd0721fa0706145943700c59b..41d89f62b179a4e992a1254b969999901fa422ba 100644 (file)
 
 #include "account.h"
 #include "configfile.h" // ONLY ACCESS THE STATIC FUNCTIONS!
-#include "creds/httpcredentials.h"
+#ifdef TOKEN_AUTH_ONLY
+# include "creds/tokencredentials.h"
+#else
+# include "creds/httpcredentials.h"
+#endif
 #include "simplesslerrorhandler.h"
 #include "syncengine.h"
 #include "common/syncjournaldb.h"
@@ -128,6 +132,7 @@ QString queryPassword(const QString &user)
     return QString::fromStdString(s);
 }
 
+#ifndef TOKEN_AUTH_ONLY
 class HttpCredentialsText : public HttpCredentials
 {
 public:
@@ -159,6 +164,7 @@ public:
 private:
     bool _sslTrusted;
 };
+#endif /* TOKEN_AUTH_ONLY */
 
 void help()
 {
@@ -441,13 +447,18 @@ int main(int argc, char **argv)
 
     auto *sslErrorHandler = new SimpleSslErrorHandler;
 
+#ifdef TOKEN_AUTH_ONLY
+    auto *cred = new TokenCredentials(user, password, "");
+    account->setCredentials(cred);
+#else
     auto *cred = new HttpCredentialsText(user, password);
-
+    account->setCredentials(cred);
     if (options.trustSSL) {
         cred->setSSLTrusted(true);
     }
+#endif
+
     account->setUrl(url);
-    account->setCredentials(cred);
     account->setSslErrorHandler(sslErrorHandler);
 
     // Perform a call to get the capabilities.