SSL and API disabled errors handling for TT-RSS
This commit is contained in:
parent
584c9e9dd1
commit
4b8d0476c7
7 changed files with 65 additions and 15 deletions
|
|
@ -969,6 +969,16 @@ Page {
|
|||
}
|
||||
}*/
|
||||
|
||||
SectionHeader {
|
||||
text: qsTr("Other")
|
||||
}
|
||||
|
||||
TextSwitch {
|
||||
text: qsTr("Ignore SSL errors")
|
||||
onCheckedChanged: settings.ignoreSslErrors = checked;
|
||||
Component.onCompleted: checked = settings.ignoreSslErrors
|
||||
}
|
||||
|
||||
Spacer {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,6 +151,14 @@ Dialog {
|
|||
}
|
||||
}
|
||||
|
||||
TextSwitch {
|
||||
text: qsTr("Ignore SSL errors")
|
||||
onCheckedChanged: {
|
||||
settings.ignoreSslErrors = checked
|
||||
}
|
||||
Component.onCompleted: checked = settings.ignoreSslErrors
|
||||
}
|
||||
|
||||
Item {
|
||||
height: Theme.itemSizeLarge
|
||||
width: Theme.itemSizeLarge
|
||||
|
|
|
|||
|
|
@ -303,17 +303,13 @@ ApplicationWindow {
|
|||
|
||||
if (code < 400)
|
||||
return;
|
||||
if (code >= 400 && code < 500) {
|
||||
if (code == 402)
|
||||
if (code === 700 || (code >= 400 && code < 500)) {
|
||||
if (code === 402)
|
||||
notification.show(qsTr("The user name or password is incorrect!"));
|
||||
/*if (code == 403) {
|
||||
notification.show(qsTr("Your login credentials have expired!"));
|
||||
if (settings.getSigninType()>0) {
|
||||
fetcher.getAuthUrl();
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
//console.log("settings.signinType",settings.getSigninType());
|
||||
else if (code === 404) // TT-RSS API disabled
|
||||
notification.show(qsTr("Access through API is disabled on a server"));
|
||||
else if (code === 700) // SSL error
|
||||
notification.show(qsTr("Problem with SSL certificate"));
|
||||
|
||||
// Sign in
|
||||
var type = settings.signinType;
|
||||
|
|
@ -333,10 +329,9 @@ ApplicationWindow {
|
|||
pageStack.push(Qt.resolvedUrl("TTRssSignInDialog.qml"),{"code": code});
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Unknown error
|
||||
notification.show(qsTr("An unknown error occurred."), qsTr("Something went wrong!"));
|
||||
notification.show(qsTr("Unknown error"));
|
||||
resetView();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ Q_SIGNALS:
|
|||
401 - SignIn failed
|
||||
402 - SignIn user/password do no match
|
||||
403 - Cookie expired
|
||||
500 - Network error
|
||||
404 - TT-RSS API disabled
|
||||
500 - Generic network error
|
||||
501 - SignIn resposne is null
|
||||
502 - Internal error
|
||||
503 - User ID is empty
|
||||
|
|
@ -107,6 +108,7 @@ Q_SIGNALS:
|
|||
506 - DB backup error
|
||||
600 - Error while parsing JSON
|
||||
601 - Unknown JSON response
|
||||
700 - Generic SSL error
|
||||
*/
|
||||
void credentialsValid();
|
||||
void errorCheckingCredentials(int code);
|
||||
|
|
|
|||
|
|
@ -932,3 +932,16 @@ void Settings::reset()
|
|||
setShowBroadcast(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setIgnoreSslErrors(bool value)
|
||||
{
|
||||
if (getIgnoreSslErrors() != value) {
|
||||
settings.setValue("ignoresslerrors", value);
|
||||
emit ignoreSslErrorsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::getIgnoreSslErrors()
|
||||
{
|
||||
return settings.value("ignoresslerrors", false).toBool();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class Settings: public QObject
|
|||
Q_PROPERTY (QString pocketToken READ getPocketToken WRITE setPocketToken NOTIFY pocketTokenChanged)
|
||||
Q_PROPERTY (QString pocketTags READ getPocketTags WRITE setPocketTags NOTIFY pocketTagsChanged)
|
||||
Q_PROPERTY (QString pocketTagsHistory READ getPocketTagsHistory WRITE setPocketTagsHistory NOTIFY pocketTagsHistoryChanged)
|
||||
Q_PROPERTY (bool ignoreSslErrors READ getIgnoreSslErrors WRITE setIgnoreSslErrors NOTIFY ignoreSslErrorsChanged)
|
||||
|
||||
public:
|
||||
static Settings* instance();
|
||||
|
|
@ -272,6 +273,9 @@ public:
|
|||
void setFeedsUpdateAtOnce(int value);
|
||||
int getFeedsUpdateAtOnce();
|
||||
|
||||
void setIgnoreSslErrors(bool value);
|
||||
bool getIgnoreSslErrors();
|
||||
|
||||
Q_INVOKABLE void setHint1Done(bool value);
|
||||
Q_INVOKABLE bool getHint1Done();
|
||||
|
||||
|
|
@ -316,6 +320,7 @@ signals:
|
|||
void pocketTagsHistoryChanged();
|
||||
void pocketFavoriteChanged();
|
||||
void pocketQuickAddChanged();
|
||||
void ignoreSslErrorsChanged();
|
||||
|
||||
/*
|
||||
501 - Unable create settings dir
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QSslError>
|
||||
#include <QtCore/qmath.h>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
|
|
@ -714,12 +715,26 @@ void TTRssFetcher::sendApiCall(const QString& op, const QString& params, ReplyCa
|
|||
connect(currentReply, &QNetworkReply::finished, this, callback);
|
||||
connect(currentReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
||||
connect(currentReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkError(QNetworkReply::NetworkError)));
|
||||
connect(currentReply, &QNetworkReply::sslErrors, [this](const QList<QSslError> &errors) {
|
||||
qWarning() << "SSL error:" << errors;
|
||||
if (Settings::instance()->getIgnoreSslErrors()) {
|
||||
qDebug() << "Ignoring SSL errors";
|
||||
currentReply->ignoreSslErrors();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool TTRssFetcher::processResponse()
|
||||
{
|
||||
if (currentReply->error() && currentReply->error() != QNetworkReply::OperationCanceledError) {
|
||||
emit error(500);
|
||||
auto e = currentReply->error();
|
||||
if (e != QNetworkReply::NoError &&
|
||||
e != QNetworkReply::OperationCanceledError) {
|
||||
qDebug() << "Request error:" << e;
|
||||
if (e == QNetworkReply::SslHandshakeFailedError) {
|
||||
emit error(700);
|
||||
} else {
|
||||
emit error(500);
|
||||
}
|
||||
setBusy(false);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -745,6 +760,8 @@ bool TTRssFetcher::processResponse()
|
|||
}
|
||||
} else if (err == "NOT_LOGGED_IN") {
|
||||
emit error(401);
|
||||
} else if (err == "API_DISABLED") {
|
||||
emit error(404);
|
||||
} else {
|
||||
emit error(601);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue