Fall back to old login flow on GS as this is not yet ready (#2: re-auth)
authorMichael Schuster <michael@schuster.ms>
Fri, 6 Dec 2019 19:14:18 +0000 (20:14 +0100)
committerMichael Schuster <48932272+misch7@users.noreply.github.com>
Fri, 6 Dec 2019 20:03:01 +0000 (21:03 +0100)
This commit ensures that the check also occurs on re-authorization in case
the user gets logged out.

See: https://github.com/nextcloud/desktop/pull/1644

Signed-off-by: Michael Schuster <michael@schuster.ms>
src/gui/creds/webflowcredentials.cpp

index e2dc10b352bb3593cf0dd84391bcb07943daf9d8..d69bb125fd3ce6598bcf9d17588e78993c844c87 100644 (file)
@@ -147,25 +147,31 @@ void WebFlowCredentials::fetchFromKeychain() {
 }
 
 void WebFlowCredentials::askFromUser() {
-    // LoginFlowV2 > WebViewFlow > OAuth > Shib > Basic
-    bool useFlow2 = (_account->serverVersionInt() >= Account::makeServerVersion(16, 0, 0));
+    // Determine if the old flow has to be used (GS for now)
+    // Do a DetermineAuthTypeJob to make sure that the server is still using Flow2
+    DetermineAuthTypeJob *job = new DetermineAuthTypeJob(_account->sharedFromThis(), this);
+    connect(job, &DetermineAuthTypeJob::authType, [this](DetermineAuthTypeJob::AuthType type) {
+        // LoginFlowV2 > WebViewFlow > OAuth > Shib > Basic
+        bool useFlow2 = (type != DetermineAuthTypeJob::WebViewFlow);
 
-    _askDialog = new WebFlowCredentialsDialog(_account, useFlow2);
+        _askDialog = new WebFlowCredentialsDialog(_account, useFlow2);
 
-    if (!useFlow2) {
-        QUrl url = _account->url();
-        QString path = url.path() + "/index.php/login/flow";
-        url.setPath(path);
-        _askDialog->setUrl(url);
-    }
+        if (!useFlow2) {
+            QUrl url = _account->url();
+            QString path = url.path() + "/index.php/login/flow";
+            url.setPath(path);
+            _askDialog->setUrl(url);
+        }
 
-    QString msg = tr("You have been logged out of %1 as user %2. Please login again")
-            .arg(_account->displayName(), _user);
-    _askDialog->setInfo(msg);
+        QString msg = tr("You have been logged out of %1 as user %2. Please login again")
+                .arg(_account->displayName(), _user);
+        _askDialog->setInfo(msg);
 
-    _askDialog->show();
+        _askDialog->show();
 
-    connect(_askDialog, &WebFlowCredentialsDialog::urlCatched, this, &WebFlowCredentials::slotAskFromUserCredentialsProvided);
+        connect(_askDialog, &WebFlowCredentialsDialog::urlCatched, this, &WebFlowCredentials::slotAskFromUserCredentialsProvided);
+    });
+    job->start();
 
     qCDebug(lcWebFlowCredentials()) << "User needs to reauth!";
 }