Showing the changes to interface/src/ui/OAuthWebViewHandler.cpp (1 of 4 files). Show all
Unified · Split
| @@ -103,8 +103,9 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz · 102 unmodified lines | |||
| 103 | codedAuthorizationURL.setQuery(authQuery); | 103 | codedAuthorizationURL.setQuery(authQuery); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | connect(_activeWebView.data(), &QWebView::urlChanged, this, &OAuthWebViewHandler::handleURLChanged); | ||
| 107 | |||
| 106 | _activeWebView->load(codedAuthorizationURL); | 108 | _activeWebView->load(codedAuthorizationURL); |
| 107 | _activeWebView->show(); | ||
| 108 | 109 | ||
| 109 | connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors, | 110 | connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors, |
| 110 | this, &OAuthWebViewHandler::handleSSLErrors); | 111 | this, &OAuthWebViewHandler::handleSSLErrors); |
| @@ -137,3 +138,17 @@ void OAuthWebViewHandler::handleLoadFinished(bool success) { · 26 unmodified lines | |||
| 137 | void OAuthWebViewHandler::handleWebViewDestroyed(QObject* destroyedObject) { | 138 | void OAuthWebViewHandler::handleWebViewDestroyed(QObject* destroyedObject) { |
| 138 | _webViewRedisplayTimer.restart(); | 139 | _webViewRedisplayTimer.restart(); |
| 139 | } | 140 | } |
| 141 | |||
| 142 | void OAuthWebViewHandler::handleURLChanged(const QUrl& url) { | ||
| 143 | // check if this is the authorization screen - if it is then we need to show the OAuthWebViewHandler | ||
| 144 | const QString ACCESS_TOKEN_URL_REGEX_STRING = "redirect_uri=[\\w:\\/\\.]+&access_token="; | ||
| 145 | QRegExp accessTokenRegex(ACCESS_TOKEN_URL_REGEX_STRING); | ||
| 146 | |||
| 147 | if (accessTokenRegex.indexIn(url.toString()) != -1) { | ||
| 148 | _activeWebView->show(); | ||
| 149 | } else if (url.toString() == DEFAULT_NODE_AUTH_URL.toString() + "/login") { | ||
| 150 | // this is a login request - we're going to close the webview and signal the AccountManager that we need a login | ||
| 151 | _activeWebView->close(); | ||
| 152 | AccountManager::getInstance().checkAndSignalForAccessToken(); | ||
| 153 | } | ||
| 154 | } | ||