Skip to content

Commit

Permalink
Wizard + OAuth: Make opening a new browser after clicking back works …
Browse files Browse the repository at this point in the history
…again

Issue #6574

When there is an error in the advanced page, OwncloudAdvancedSetupPage::updateStatus
(and others) call completeChanged(), which is connected to
QWizardPrivate::_q_updateButtonStates which will re-enable the back button from the
last page.

When the user click "back" and re-open the browser, the account's credentials
already have a oauth token set. So the call to the API to get a new token fails
because we use the previous token instead of using the client's secret_id.
Fix this with the HttpCredentials::DontAddCredentialsAttribute.

Now, this is still not working because the session cookies are confusing the
server.  So we'll clear the cookies when re-opening the browser
  • Loading branch information
ogoffart committed Jun 19, 2018
1 parent ae80317 commit 850dc67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gui/creds/oauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QJsonDocument>
#include "theme.h"
#include "networkjobs.h"
#include "creds/httpcredentials.h"

namespace OCC {

Expand Down Expand Up @@ -85,6 +86,8 @@ void OAuth::start()
QString basicAuth = QString("%1:%2").arg(
Theme::instance()->oauthClientId(), Theme::instance()->oauthClientSecret());
req.setRawHeader("Authorization", "Basic " + basicAuth.toUtf8().toBase64());
// We just added the Authorization header, don't let HttpCredentialsAccessManager tamper with it
req.setAttribute(HttpCredentials::DontAddCredentialsAttribute, true);

auto requestBody = new QBuffer;
QUrlQuery arguments(QString(
Expand Down
1 change: 1 addition & 0 deletions src/gui/wizard/owncloudoauthcredspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ OwncloudOAuthCredsPage::OwncloudOAuthCredsPage()

connect(_ui.openLinkButton, &QCommandLinkButton::clicked, [this] {
_ui.errorLabel->hide();
qobject_cast<OwncloudWizard *>(wizard())->account()->clearCookieJar(); // #6574
if (_asyncAuth)
_asyncAuth->openBrowser();
});
Expand Down

0 comments on commit 850dc67

Please sign in to comment.