History

expose access token from AccountManager

Stephen Birarda committed 12 years ago

Commit 4936fb31 parent 709bcdb7 files · +28 −12Browse files

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

Unified · Split

interface/src/ui/OAuthWebViewHandler.cpp+18−1
@@ -63,7 +63,24 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz · 62 unmodified lines
6363 _activeWebView->setAttribute(Qt::WA_DeleteOnClose);
6464
6565 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);
6784 _activeWebView->show();
6885
6986 connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,

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