MecElectronics: Return proper error code on wrong authentication

master
Michael Zanetti 2022-03-23 17:53:35 +01:00
parent fc523cc7e6
commit c2f13b16fe
3 changed files with 16 additions and 0 deletions

View File

@ -93,7 +93,13 @@ void IntegrationPluginMecMeter::confirmPairing(ThingPairingInfo *info, const QSt
connect(reply, &QNetworkReply::finished, info, [=](){ connect(reply, &QNetworkReply::finished, info, [=](){
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
qCWarning(dcMecElectronics()) << "Error connecting to mecmeter:" << reply->error() << reply->errorString(); qCWarning(dcMecElectronics()) << "Error connecting to mecmeter:" << reply->error() << reply->errorString();
// Device responds with InternalServerError on wrong login
if (reply->error() == QNetworkReply::InternalServerError) {
info->finish(Thing::ThingErrorAuthenticationFailure, QT_TR_NOOP("The login credentials are not valid."));
return;
}
info->finish(Thing::ThingErrorHardwareFailure); info->finish(Thing::ThingErrorHardwareFailure);
return;
} }
pluginStorage()->beginGroup(meterId); pluginStorage()->beginGroup(meterId);

View File

@ -8,6 +8,11 @@
<source>Please enter your login credentials for the mecMeter.</source> <source>Please enter your login credentials for the mecMeter.</source>
<translation>Bitte gib Deine Logindaten für das mecMeter ein.</translation> <translation>Bitte gib Deine Logindaten für das mecMeter ein.</translation>
</message> </message>
<message>
<location filename="../integrationpluginmecelectronics.cpp" line="98"/>
<source>The login credentials are not valid.</source>
<translation>Die eingegebenen Login-Daten sind nicht korrekt.</translation>
</message>
</context> </context>
<context> <context>
<name>mecElectronics</name> <name>mecElectronics</name>

View File

@ -8,6 +8,11 @@
<source>Please enter your login credentials for the mecMeter.</source> <source>Please enter your login credentials for the mecMeter.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<location filename="../integrationpluginmecelectronics.cpp" line="98"/>
<source>The login credentials are not valid.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>mecElectronics</name> <name>mecElectronics</name>