Fix login flow with system proxy
authorRoeland Jago Douma <roeland@famdouma.nl>
Wed, 30 Jan 2019 21:48:40 +0000 (22:48 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 31 Jan 2019 12:45:40 +0000 (13:45 +0100)
I must admit why this works is puzzling me. However if I just use a system
proxy without this it doesn't work. I suspect a Qt bug but will have to
dig deeper to find out if that is the case.

For now this little hack will have to do.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
src/gui/wizard/webviewpage.cpp
src/gui/wizard/webviewpage.h

index 45028f6a5de2ae6b04c80336535e557b31f03558..f9deeb83f6649fc0c39aac39192814335528a347 100644 (file)
@@ -3,6 +3,7 @@
 #include <QWebEngineUrlRequestJob>
 #include <QProgressBar>
 #include <QVBoxLayout>
+#include <QNetworkProxyFactory>
 
 #include "owncloudwizard.h"
 #include "creds/webflowcredentials.h"
@@ -27,9 +28,17 @@ WebViewPage::WebViewPage(QWidget *parent)
     setLayout(layout);
 
     connect(_webView, &WebView::urlCatched, this, &WebViewPage::urlCatched);
+
+    _useSystemProxy = QNetworkProxyFactory::usesSystemConfiguration();
+}
+
+WebViewPage::~WebViewPage() {
+    QNetworkProxyFactory::setUseSystemConfiguration(_useSystemProxy);
 }
 
 void WebViewPage::initializePage() {
+    QNetworkProxy::setApplicationProxy(QNetworkProxy::applicationProxy());
+
     QString url;
     if (_ocWizard->registration()) {
         url = "https://nextcloud.com/register";
index 76735aaef1d8bc986eeb9eb13def13a58f9e1804..65f00c33bb9692e9b5be648eac40500a6b4e8d76 100644 (file)
@@ -14,6 +14,7 @@ class WebViewPage : public AbstractCredentialsWizardPage
     Q_OBJECT
 public:
     WebViewPage(QWidget *parent = nullptr);
+    ~WebViewPage();
 
     void initializePage() override;
     int nextId() const override;
@@ -34,6 +35,8 @@ private:
 
     QString _user;
     QString _pass;
+
+    bool _useSystemProxy;
 };
 
 }