Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve ToS handling #7856

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/gui/connectionvalidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* for more details.
*/

#include <QJsonDocument>

Check failure on line 15 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/connectionvalidator.cpp:15:10 [clang-diagnostic-error]

'QJsonDocument' file not found
#include <QJsonObject>
#include <QJsonArray>
#include <QLoggingCategory>
Expand Down Expand Up @@ -221,13 +221,20 @@
stat = CredentialsWrong;

} else if (reply->error() != QNetworkReply::NoError) {
_errors << job->errorStringParsingBody();
QByteArray body;

Check warning on line 224 in src/gui/connectionvalidator.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/connectionvalidator.cpp:224:20 [cppcoreguidelines-init-variables]

variable 'body' is not initialized
_errors << job->errorStringParsingBody(&body);

const int httpStatus =
reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (httpStatus == 503) {
_errors.clear();
stat = ServiceUnavailable;
} else if (httpStatus == 403) {
const auto davException = job->errorStringParsingBodyException(body);
if (davException == QStringLiteral(R"(OCA\TermsOfService\TermsNotSignedException)")) {
qCInfo(lcConnectionValidator) << "The terms of service need to be signed";
stat = NeedToSignTermsOfService;
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/gui/owncloudsetupwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* for more details.
*/

#include <QAbstractButton>

Check failure on line 16 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:16:10 [clang-diagnostic-error]

'QAbstractButton' file not found
#include <QtCore>
#include <QProcess>
#include <QMessageBox>
Expand All @@ -31,6 +31,7 @@
#include "networkjobs.h"
#include "owncloudgui.h"
#include "owncloudsetupwizard.h"
#include "owncloudpropagator_p.h"
#include "sslerrordialog.h"
#include "wizard/owncloudwizard.h"
#include "wizard/owncloudwizardcommon.h"
Expand Down Expand Up @@ -422,10 +423,17 @@

// Provide messages for other errors, such as invalid credentials.
} else if (reply->error() != QNetworkReply::NoError) {
auto davException = OCC::getExceptionFromReply(reply);

if (!_ocWizard->account()->credentials()->stillValid(reply)) {

Check warning on line 428 in src/gui/owncloudsetupwizard.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/owncloudsetupwizard.cpp:428:70 [bugprone-branch-clone]

repeated branch in conditional chain
errorMsg = tr("Access forbidden by server. To verify that you have proper access, "
"<a href=\"%1\">click here</a> to access the service with your browser.")
.arg(Utility::escape(_ocWizard->account()->url().toString()));
} else if (!davException.first.isEmpty() && davException.first == QStringLiteral(R"(OCA\TermsOfService\TermsNotSignedException)")) {
qCInfo(lcWizard) << "Terms of service not accepted yet!";
// TODO: it would be cool to display a new wizard page containing the terms of service
errorMsg = tr("Please accept the <a href=\"%1\">Terms of Service</a> with your browser and try again.")
.arg(Utility::escape(_ocWizard->account()->url().toString()));
} else {
errorMsg = job->errorStringParsingBody();
}
Expand Down
10 changes: 10 additions & 0 deletions src/gui/tray/syncstatussummary.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/tray/syncstatussummary.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/tray/syncstatussummary.cpp

File src/gui/tray/syncstatussummary.cpp does not conform to Custom style guidelines. (lines 128, 349)
* Copyright (C) by Felix Weilbach <felix.weilbach@nextcloud.com>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -14,6 +14,7 @@

#include "syncstatussummary.h"
#include "accountfwd.h"
#include "accountstate.h"
#include "folderman.h"
#include "navigationpanehelper.h"
#include "networkjobs.h"
Expand Down Expand Up @@ -124,6 +125,10 @@
setTotalFiles(0);
setSyncStatusString(tr("Offline"));
setSyncStatusDetailString("");
if (_accountState->state() == AccountState::NeedToSignTermsOfService)
{
setSyncStatusDetailString(tr("You need to accept the terms of service"));
}
setSyncIcon(Theme::instance()->folderOffline());
return;
}
Expand Down Expand Up @@ -340,6 +345,11 @@
setSyncStatusDetailString("");
if (_accountState && !_accountState->isConnected()) {
setSyncStatusString(tr("Offline"));
// TODO: remove this, this is intentionally in caps to see that this is temporary
if (_accountState->state() == AccountState::NeedToSignTermsOfService)
{
setSyncStatusDetailString(tr("NEEDS TOS <a href=\"%1\">click here</a>").arg(_accountState->account()->url().toString()));
}
setSyncIcon(Theme::instance()->folderOffline());
} else {
setSyncStatusString(tr("All synced!"));
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/owncloudpropagator_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ inline QPair<QByteArray, QByteArray> getExceptionFromReply(QNetworkReply * const
return {};
}
const auto httpStatusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
// only for BadRequest and UnsupportedMediaType
if (httpStatusCode != 400 && httpStatusCode != 415) {
// only for BadRequest, Forbidden, and UnsupportedMediaType
if (!(httpStatusCode == 400 || httpStatusCode == 403 || httpStatusCode == 415)) {
return {};
}

Expand Down
Loading