]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
AccountManager: take theURL from the Theme rather than from the config if the theme...
authorOlivier Goffart <olivier@woboq.com>
Fri, 15 Apr 2016 11:16:49 +0000 (13:16 +0200)
committerOlivier Goffart <olivier@woboq.com>
Fri, 15 Apr 2016 11:16:49 +0000 (13:16 +0200)
That way an upgrade of the client can actually change the URL
Issue https://github.com/owncloud/enterprise/issues/1113
https://github.com/owncloud/enterprise/issues/1126

In addition to restoring commit 7e5d89293d7bd52ac42d026d34a8154fbbdf33bb, this
add a way to override the auth type

src/gui/accountmanager.cpp
src/libsync/theme.cpp
src/libsync/theme.h

index 90924bbec199778e004bed6f72d143f3fd0e88eb..e4b386d765be20ae84993bdeb032b494701288e2 100644 (file)
@@ -211,19 +211,31 @@ AccountPtr AccountManager::loadAccountHelper(QSettings& settings)
 {
     auto acc = createAccount();
 
-    acc->setUrl(settings.value(QLatin1String(urlC)).toUrl());
+    QString authType = settings.value(QLatin1String(authTypeC)).toString();
+    QString overrideUrl = Theme::instance()->overrideServerUrl();
+    if( !overrideUrl.isEmpty() ) {
+        // if there is a overrideUrl, don't even bother reading from the config as all the accounts
+        // must use the overrideUrl
+        acc->setUrl(overrideUrl);
+        auto forceAuth = Theme::instance()->forceConfigAuthType();
+        if (!forceAuth.isEmpty()) {
+            authType = forceAuth;
+        }
+    } else {
+        acc->setUrl(settings.value(QLatin1String(urlC)).toUrl());
+    }
     acc->_serverVersion = settings.value(QLatin1String(serverVersionC)).toString();
 
     // We want to only restore settings for that auth type and the user value
     acc->_settingsMap.insert(QLatin1String(userC), settings.value(userC));
-    QString authTypePrefix = settings.value(authTypeC).toString() + "_";
+    QString authTypePrefix = authType + "_";
     Q_FOREACH(QString key, settings.childKeys()) {
         if (!key.startsWith(authTypePrefix))
             continue;
         acc->_settingsMap.insert(key, settings.value(key));
     }
 
-    acc->setCredentials(CredentialsFactory::create(settings.value(QLatin1String(authTypeC)).toString()));
+    acc->setCredentials(CredentialsFactory::create(authType));
 
     // now the cert, it is in the general group
     settings.beginGroup(QLatin1String("General"));
index 1bc3477d4f3dfb65875e82514be7924623ea4ad1..62eccb5a30746dc500e99683b406272e8eebcb2a 100644 (file)
@@ -216,6 +216,12 @@ QString Theme::overrideServerUrl() const
     return QString::null;
 }
 
+QString Theme::forceConfigAuthType() const
+{
+    return QString();
+}
+
+
 QString Theme::defaultClientFolder() const
 {
     return appName();
index 4fedd41f2ca56a24f3cf1799178b1cb9bbea6f5c..657e4694e81985663e32870d216447857f5b4b6c 100644 (file)
@@ -129,6 +129,13 @@ public:
      */
     virtual QString overrideServerUrl() const;
 
+    /**
+     * This is only usefull when previous version had a different overrideServerUrl
+     * with a different auth type in that case You should then specify "http" or "shibboleth".
+     * Normaly this should be left empty.
+     */
+    virtual QString forceConfigAuthType() const;
+
     /**
      * The default folder name without path on the server at setup time.
      */