Http credentials: Fix behavior for bad password #5989

When the GET request from askFromUser is scheduled on the QNAM inside
the slot that handles the QNetworkReply::finished signal, it seems to
not get processed at all.

This workaround moves the sending of the new GET to the event loop,
sidestepping the problem.
This commit is contained in:
Christian Kamm 2017-09-07 11:10:23 +02:00 committed by Roeland Jago Douma
parent 8a094d2b0e
commit 3591849279
No known key found for this signature in database
GPG key ID: F941078878347C0C
2 changed files with 11 additions and 1 deletions

View file

@ -30,6 +30,14 @@ using namespace QKeychain;
namespace OCC {
void HttpCredentialsGui::askFromUser()
{
// Unfortunately there's a bug that doesn't allow us to send the "is this
// OAuth2 or Basic auth?" GET request directly. Scheduling it for the event
// loop works though. See #5989.
QMetaObject::invokeMethod(this, "askFromUserAsync", Qt::QueuedConnection);
}
void HttpCredentialsGui::askFromUserAsync()
{
_password = QString(); // So our QNAM does not add any auth

View file

@ -48,7 +48,7 @@ public:
* This will query the server and either uses OAuth via _asyncAuth->start()
* or call showDialog to ask the password
*/
Q_INVOKABLE void askFromUser() Q_DECL_OVERRIDE;
void askFromUser() Q_DECL_OVERRIDE;
/**
* In case of oauth, return an URL to the link to open the browser.
* An invalid URL otherwise
@ -65,6 +65,8 @@ signals:
void authorisationLinkChanged();
private:
Q_INVOKABLE void askFromUserAsync();
QScopedPointer<OAuth, QScopedPointerObjectDeleteLater<OAuth>> _asyncAuth;
};