Merge pull request #1057 from nextcloud/fix/proxy-login-flow

Fix login flow with system proxy
This commit is contained in:
Roeland Jago Douma 2019-01-31 16:11:08 +01:00 committed by GitHub
commit 822c386709
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 23 deletions

View file

@ -80,8 +80,16 @@ void ClientProxy::setupQtProxyFromConfig()
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy); QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
break; break;
case QNetworkProxy::DefaultProxy: case QNetworkProxy::DefaultProxy:
qCInfo(lcClientProxy) << "Set proxy configuration to use system configuration"; qCInfo(lcClientProxy) << "Set proxy configuration to use the prefered system proxy for http tcp connections";
QNetworkProxyFactory::setUseSystemConfiguration(true); {
QNetworkProxyQuery query;
query.setProtocolTag("http");
query.setQueryType(QNetworkProxyQuery::TcpSocket);
auto proxies = QNetworkProxyFactory::proxyForQuery(query);
proxy = proxies.first();
}
QNetworkProxyFactory::setUseSystemConfiguration(false);
QNetworkProxy::setApplicationProxy(proxy);
break; break;
case QNetworkProxy::Socks5Proxy: case QNetworkProxy::Socks5Proxy:
proxy.setType(QNetworkProxy::Socks5Proxy); proxy.setType(QNetworkProxy::Socks5Proxy);

View file

@ -3,6 +3,7 @@
#include <QWebEngineUrlRequestJob> #include <QWebEngineUrlRequestJob>
#include <QProgressBar> #include <QProgressBar>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QNetworkProxyFactory>
#include "owncloudwizard.h" #include "owncloudwizard.h"
#include "creds/webflowcredentials.h" #include "creds/webflowcredentials.h"
@ -27,9 +28,17 @@ WebViewPage::WebViewPage(QWidget *parent)
setLayout(layout); setLayout(layout);
connect(_webView, &WebView::urlCatched, this, &WebViewPage::urlCatched); connect(_webView, &WebView::urlCatched, this, &WebViewPage::urlCatched);
//_useSystemProxy = QNetworkProxyFactory::usesSystemConfiguration();
}
WebViewPage::~WebViewPage() {
//QNetworkProxyFactory::setUseSystemConfiguration(_useSystemProxy);
} }
void WebViewPage::initializePage() { void WebViewPage::initializePage() {
//QNetworkProxy::setApplicationProxy(QNetworkProxy::applicationProxy());
QString url; QString url;
if (_ocWizard->registration()) { if (_ocWizard->registration()) {
url = "https://nextcloud.com/register"; url = "https://nextcloud.com/register";

View file

@ -14,6 +14,7 @@ class WebViewPage : public AbstractCredentialsWizardPage
Q_OBJECT Q_OBJECT
public: public:
WebViewPage(QWidget *parent = nullptr); WebViewPage(QWidget *parent = nullptr);
~WebViewPage();
void initializePage() override; void initializePage() override;
int nextId() const override; int nextId() const override;
@ -34,6 +35,8 @@ private:
QString _user; QString _user;
QString _pass; QString _pass;
bool _useSystemProxy;
}; };
} }