History

only display the OAuthWebViewHandler when we need to ask user for authorization

Stephen Birarda committed 12 years ago

Commit 82bf6001 parent 62f85d04 files · +25 −4Browse files

Showing the changes to interface/src/ui/OAuthWebViewHandler.cpp (1 of 4 files). Show all

Unified · Split

interface/src/ui/OAuthWebViewHandler.cpp+16−1
@@ -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
137void OAuthWebViewHandler::handleWebViewDestroyed(QObject* destroyedObject) {138void OAuthWebViewHandler::handleWebViewDestroyed(QObject* destroyedObject) {
138 _webViewRedisplayTimer.restart();139 _webViewRedisplayTimer.restart();
139}140}
141
142void 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}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t