Skip to content

Commit

Permalink
A 404 during a token refresh is no reason to gice up
Browse files Browse the repository at this point in the history
Fixes: #9245
  • Loading branch information
TheOneRing committed Jan 21, 2022
1 parent 2f5547e commit 8ee7adf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelog/unreleased/9245
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enhancement: Don't log out if we receive a 404 during token refresh

https://github.com/owncloud/client/issues/9245
https://github.com/owncloud/client/pull/9380
12 changes: 10 additions & 2 deletions src/libsync/creds/httpcredentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <QSettings>
#include <QSslKey>

#include <chrono>

using namespace std::chrono_literals;

Q_LOGGING_CATEGORY(lcHttpCredentials, "sync.credentials.http", QtInfoMsg)
Q_LOGGING_CATEGORY(lcHttpLegacyCredentials, "sync.credentials.http.legacy", QtInfoMsg)

Expand Down Expand Up @@ -271,12 +275,16 @@ bool HttpCredentials::refreshAccessToken()
case QNetworkReply::ServiceUnavailableError:
Q_FALLTHROUGH();
case QNetworkReply::UnknownNetworkError:
QTimer::singleShot(30000, this, &HttpCredentials::refreshAccessToken);
QTimer::singleShot(30s, this, &HttpCredentials::refreshAccessToken);
break;
case QNetworkReply::ContentNotFoundError:
// 404: not part of the protocol, bigip f5?
QTimer::singleShot(0, this, &HttpCredentials::refreshAccessToken);
break;
default:
// something is broken
// start fresh
qCWarning(lcHttpCredentials) << "Token refresh encountered an unsupported network error" << errorString << "-> log out";
qCWarning(lcHttpCredentials) << "Token refresh encountered an unsupported network error" << error << ": " << errorString << "-> log out";
forgetSensitiveData();
Q_EMIT _account->invalidCredentials();
}
Expand Down

0 comments on commit 8ee7adf

Please sign in to comment.