aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-11-19 17:57:41 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-11-19 17:57:41 +0900
commit5937127b73a82fc86f6546397373ce9dbaf4e560 (patch)
tree1e3b4e5ddd50e8a4b605e7e599591d47fe9bed55 /lib/connection.cpp
parent1d57741c679ec3112ae45e833b8f152fa737b944 (diff)
downloadlibquotient-5937127b73a82fc86f6546397373ce9dbaf4e560.tar.gz
libquotient-5937127b73a82fc86f6546397373ce9dbaf4e560.zip
BaseJob: Don't send accessToken if not needed; send again on 401
The first part closes #358; the second part is a workaround for non-standard cases when endpoints without security by the spec turn out to be secured (in particular, the case of authenticating media servers).
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 5ee7e84e..c830557c 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -343,7 +343,8 @@ void Connection::logout()
}
const auto* job = callApi<LogoutJob>();
connect(job, &LogoutJob::finished, this, [this, job, syncWasRunning] {
- if (job->status().good() || job->error() == BaseJob::ContentAccessError) {
+ if (job->status().good() || job->error() == BaseJob::Unauthorised
+ || job->error() == BaseJob::ContentAccessError) {
if (d->syncLoopConnection)
disconnect(d->syncLoopConnection);
d->data->setToken({});
@@ -380,9 +381,9 @@ void Connection::sync(int timeout)
});
connect(job, &SyncJob::failure, this, [this, job] {
d->syncJob = nullptr;
- if (job->error() == BaseJob::ContentAccessError) {
- qCWarning(SYNCJOB) << "Sync job failed with ContentAccessError - "
- "login expired?";
+ if (job->error() == BaseJob::Unauthorised) {
+ qCWarning(SYNCJOB)
+ << "Sync job failed with Unauthorised - login expired?";
emit loginError(job->errorString(), job->rawDataSample());
} else
emit syncError(job->errorString(), job->rawDataSample());