Http credentials: Fix behavior for bad password #5989
authorChristian Kamm <mail@ckamm.de>
Thu, 7 Sep 2017 09:10:23 +0000 (11:10 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 5 Oct 2017 20:01:04 +0000 (22:01 +0200)
When the GET request from askFromUser is scheduled on the QNAM inside
the slot that handles the QNetworkReply::finished signal, it seems to
not get processed at all.

This workaround moves the sending of the new GET to the event loop,
sidestepping the problem.

src/gui/creds/httpcredentialsgui.cpp
src/gui/creds/httpcredentialsgui.h

index 2ab2d0d30eb37afe7722178ff858385de893a928..e65554f4987376112896c6e62e4f36fff907b2ec 100644 (file)
@@ -30,6 +30,14 @@ using namespace QKeychain;
 namespace OCC {
 
 void HttpCredentialsGui::askFromUser()
+{
+    // Unfortunately there's a bug that doesn't allow us to send the "is this
+    // OAuth2 or Basic auth?" GET request directly. Scheduling it for the event
+    // loop works though. See #5989.
+    QMetaObject::invokeMethod(this, "askFromUserAsync", Qt::QueuedConnection);
+}
+
+void HttpCredentialsGui::askFromUserAsync()
 {
     _password = QString(); // So our QNAM does not add any auth
 
index fefc4dd1d28e319cd5a43115287083ced367bb6e..94ebda152f611282b481fd2e39fb93f376eaf3e2 100644 (file)
@@ -48,7 +48,7 @@ public:
      * This will query the server and either uses OAuth via _asyncAuth->start()
      * or call showDialog to ask the password
      */
-    Q_INVOKABLE void askFromUser() Q_DECL_OVERRIDE;
+    void askFromUser() Q_DECL_OVERRIDE;
     /**
      * In case of oauth, return an URL to the link to open the browser.
      * An invalid URL otherwise
@@ -65,6 +65,8 @@ signals:
     void authorisationLinkChanged();
 
 private:
+    Q_INVOKABLE void askFromUserAsync();
+
     QScopedPointer<OAuth, QScopedPointerObjectDeleteLater<OAuth>> _asyncAuth;
 };