Showing the changes to interface/src/ui/OAuthWebViewHandler.cpp (1 of 2 files). Show all
Unified · Split
| @@ -38,8 +38,10 @@ void OAuthWebViewHandler::addHighFidelityRootCAToSSLConfig() { · 37 unmodified lines | ||
| 38 | 38 | QSslConfiguration::setDefaultConfiguration(sslConfig); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | +const int WEB_VIEW_REDISPLAY_ELAPSED_MSECS = 5 * 1000; | |
| 42 | + | |
| 41 | 43 | void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authorizationURL) { |
| 42 | − if (!_activeWebView) { | |
| 44 | + if (!_activeWebView && _webViewRedisplayTimer.elapsed() >= WEB_VIEW_REDISPLAY_ELAPSED_MSECS) { | |
| 43 | 45 | _activeWebView = new QWebView; |
| 44 | 46 | |
| 45 | 47 | // keep the window on top and delete it when it closes |
| @@ -52,9 +54,24 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz · 6 unmodified lines | ||
| 52 | 54 | |
| 53 | 55 | connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors, |
| 54 | 56 | this, &OAuthWebViewHandler::handleSSLErrors); |
| 57 | + connect(_activeWebView, &QWebView::loadFinished, this, &OAuthWebViewHandler::handleLoadFinished); | |
| 58 | + | |
| 59 | + // connect to the destroyed signal so after the web view closes we can start a timer | |
| 60 | + connect(_activeWebView, &QWebView::destroyed, this, &OAuthWebViewHandler::handleWebViewDestroyed); | |
| 55 | 61 | } |
| 56 | 62 | } |
| 57 | 63 | |
| 58 | 64 | void OAuthWebViewHandler::handleSSLErrors(QNetworkReply* networkReply, const QList<QSslError>& errorList) { |
| 59 | 65 | qDebug() << "SSL Errors:" << errorList; |
| 60 | 66 | } |
| 67 | + | |
| 68 | +void OAuthWebViewHandler::handleLoadFinished(bool success) { | |
| 69 | + if (success && _activeWebView->url().host() == NodeList::getInstance()->getDomainHandler().getHostname()) { | |
| 70 | + qDebug() << "OAuth authorization code passed successfully to domain-server."; | |
| 71 | + _activeWebView->close(); | |
| 72 | + } | |
| 73 | +} | |
| 74 | + | |
| 75 | +void OAuthWebViewHandler::handleWebViewDestroyed(QObject* destroyedObject) { | |
| 76 | + _webViewRedisplayTimer.restart(); | |
| 77 | +} | |