Showing the changes to interface/src/ui/OAuthWebViewHandler.cpp (1 of 7 files). Show all
Unified · Split
| @@ -63,7 +63,24 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz · 62 unmodified lines | |||
| 63 | _activeWebView->setAttribute(Qt::WA_DeleteOnClose); | 63 | _activeWebView->setAttribute(Qt::WA_DeleteOnClose); |
| 64 | 64 | ||
| 65 | qDebug() << "Displaying QWebView for OAuth authorization at" << authorizationURL.toString(); | 65 | qDebug() << "Displaying QWebView for OAuth authorization at" << authorizationURL.toString(); |
| 66 | _activeWebView->load(authorizationURL); | 66 | |
| 67 | AccountManager& accountManager = AccountManager::getInstance(); | ||
| 68 | |||
| 69 | QUrl codedAuthorizationURL = authorizationURL; | ||
| 70 | |||
| 71 | // check if we have an access token for this host - if so we can bypass login by adding it to the URL | ||
| 72 | if (accountManager.getAuthURL().host() == authorizationURL.host() | ||
| 73 | && accountManager.hasValidAccessToken()) { | ||
| 74 | |||
| 75 | const QString ACCESS_TOKEN_QUERY_STRING_KEY = "access_token"; | ||
| 76 | |||
| 77 | QUrlQuery authQuery(codedAuthorizationURL); | ||
| 78 | authQuery.addQueryItem(ACCESS_TOKEN_QUERY_STRING_KEY, accountManager.getAccountInfo().getAccessToken().token); | ||
| 79 | |||
| 80 | codedAuthorizationURL.setQuery(authQuery); | ||
| 81 | } | ||
| 82 | |||
| 83 | _activeWebView->load(codedAuthorizationURL); | ||
| 67 | _activeWebView->show(); | 84 | _activeWebView->show(); |
| 68 | 85 | ||
| 69 | connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors, | 86 | connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors, |