Some optimalizations on OAuth process.

This commit is contained in:
Martin Rotter 2017-12-15 09:11:07 +01:00
parent 4175dc2265
commit f23e1aec73
5 changed files with 14 additions and 5 deletions

View File

@ -26,6 +26,7 @@
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "network-web/networkfactory.h"
#include "network-web/webfactory.h"
#include "services/inoreader/definitions.h"
@ -186,7 +187,10 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
qDebug() << "Token response:" << json_document.toJson();
if (root_obj.keys().contains("error")) {
if (network_reply->error() != QNetworkReply::NetworkError::NoError) {
emit tokensRetrieveError(QString(), NetworkFactory::networkErrorText(network_reply->error()));
}
else if (root_obj.keys().contains("error")) {
QString error = root_obj.value("error").toString();
QString error_description = root_obj.value("error_description").toString();

View File

@ -164,11 +164,11 @@ void GmailServiceRoot::start(bool freshly_activated) {
loadFromDatabase();
loadCacheFromFile(accountId());
m_network->oauth()->login();
if (childCount() <= 1) {
syncIn();
}
m_network->oauth()->login();
}
void GmailServiceRoot::stop() {

View File

@ -269,6 +269,8 @@ void GmailNetworkFactory::onTokensError(const QString& error, const QString& err
QSystemTrayIcon::Critical,
nullptr, false,
[this]() {
m_oauth2->setAccessToken(QString());
m_oauth2->setRefreshToken(QString());
m_oauth2->login();
});
}

View File

@ -122,11 +122,12 @@ void InoreaderServiceRoot::start(bool freshly_activated) {
loadFromDatabase();
loadCacheFromFile(accountId());
m_network->oauth()->login();
if (childCount() <= 1) {
syncIn();
}
else {
m_network->oauth()->login();
}
}
void InoreaderServiceRoot::stop() {

View File

@ -283,6 +283,8 @@ void InoreaderNetworkFactory::onTokensError(const QString& error, const QString&
QSystemTrayIcon::Critical,
nullptr, false,
[this]() {
m_oauth2->setAccessToken(QString());
m_oauth2->setRefreshToken(QString());
m_oauth2->login();
});
}