diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-12-10 12:52:38 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-12-15 12:52:23 +0300 |
commit | 4ba37025f4b5ac4a2a6cde6aac7d4a5896cfbac1 (patch) | |
tree | 7556af46a6fa71095136786095fe595cef44c941 /src/libsync | |
parent | c8dd64d8fdd8913341b498d4c18da64dadbf8523 (diff) |
Restart oauth on error
Fixes: #9196
Diffstat (limited to 'src/libsync')
-rw-r--r-- | src/libsync/creds/oauth.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libsync/creds/oauth.cpp b/src/libsync/creds/oauth.cpp index e258bca77..e729d63dc 100644 --- a/src/libsync/creds/oauth.cpp +++ b/src/libsync/creds/oauth.cpp @@ -224,6 +224,10 @@ void OAuth::startAuthentication() httpReplyAndClose(socket, QByteArrayLiteral("400 Bad Request"), QByteArrayLiteral("<html><head><title>400 Bad Request</title></head><body><center><h1>400 Bad Request</h1></center></body></html>")); return; } + // we only allow one response + qCDebug(lcOauth) << "Recieved the first valid request, stoping to listen"; + _server.close(); + auto job = postTokenRequest({ { QStringLiteral("grant_type"), QStringLiteral("authorization_code") }, { QStringLiteral("code"), args.queryItemValue(QStringLiteral("code")) }, @@ -231,10 +235,6 @@ void OAuth::startAuthentication() { QStringLiteral("code_verifier"), QString::fromUtf8(_pkceCodeVerifier) }, }); QObject::connect(job, &SimpleNetworkJob::finishedSignal, this, [this, socket](QNetworkReply *reply) { - qScopeGuard([this] { - // close the server once we are done here - _server.close(); - }); const auto jsonData = reply->readAll(); QJsonParseError jsonParseError; const auto data = QJsonDocument::fromJson(jsonData, &jsonParseError).object().toVariantMap(); |