Respect unauthorized api response when query other gateways
@@ -365,9 +365,17 @@ void GatewayPrivate::handleEventStateOffline(GW_Event event)
pings = 0;
QString url;
+ if (!apikey.isEmpty())
+ {
url.sprintf("http://%s:%u/api/%s/config",
qPrintable(address.toString()), port, qPrintable(apikey));
+ }
+ else
+ {
+ url.sprintf("http://%s:%u/api/config", qPrintable(address.toString()), port);
+ }
+
reply = manager->get(QNetworkRequest(url));
QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
manager->parent(), SLOT(error(QNetworkReply::NetworkError)));
@@ -388,6 +396,11 @@ void GatewayPrivate::handleEventStateOffline(GW_Event event)
if (code == 403)
{
state = Gateway::StateNotAuthorized;
+ if (!apikey.isEmpty())
+ {
+ apikey.clear();
+ needSaveDatabase = true;
+ }
startTimer(5000, ActionProcess);
}
else if (code == 200)
