Skip to content

Commit 5aa99b8

Browse files
authored
MID handle error 401 (open-eid#1385)
IB-8800 Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent 371a2f2 commit 5aa99b8

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

client/dialogs/MobileProgress.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ background-color: #007aff;
125125
return returnError(tr("Failed to connect with service server. Please check your network settings or try again later."));
126126
case QNetworkReply::HostNotFoundError:
127127
case QNetworkReply::AuthenticationRequiredError:
128+
case QNetworkReply::InternalServerError:
128129
return returnError(tr("Failed to send request. Check your %1 service access settings.").arg(tr("mobile-ID")));
129130
default:
130131
{
@@ -154,19 +155,19 @@ background-color: #007aff;
154155
if(result.isEmpty())
155156
return returnError(tr("Failed to parse JSON content"));
156157

157-
if(result.contains(QStringLiteral("error")))
158+
if(result.contains(QLatin1String("error")))
158159
{
159-
QString error =result[QStringLiteral("error")].toString();
160-
if(error == QStringLiteral("phoneNumber must contain of + and numbers(8-30)"))
160+
QString error = result[QLatin1String("error")].toString();
161+
if(error == QLatin1String("phoneNumber must contain of + and numbers(8-30)"))
161162
returnError(tr("Please include correct country code."));
162163
else
163164
returnError(tr(error.toUtf8().constData()));
164165
return;
165166
}
166-
if(result.contains(QStringLiteral("cert")))
167+
if(result.contains(QLatin1String("cert")))
167168
{
168169
try {
169-
QByteArray b64 = QByteArray::fromBase64(result.value(QStringLiteral("cert")).toString().toUtf8());
170+
QByteArray b64 = QByteArray::fromBase64(result.value(QLatin1String("cert")).toString().toUtf8());
170171
d->cert = X509Cert((const unsigned char*)b64.constData(), size_t(b64.size()), X509Cert::Der);
171172
d->hide();
172173
d->l.exit(QDialog::Accepted);
@@ -175,32 +176,32 @@ background-color: #007aff;
175176
}
176177
return;
177178
}
178-
if(result.contains(QStringLiteral("sessionID")))
179-
d->sessionID = result.value(QStringLiteral("sessionID")).toString();
180-
else if(result.value(QStringLiteral("state")).toString() != QStringLiteral("RUNNING"))
179+
if(result.contains(QLatin1String("sessionID")))
180+
d->sessionID = result.value(QLatin1String("sessionID")).toString();
181+
else if(result.value(QLatin1String("state")).toString() != QLatin1String("RUNNING"))
181182
{
182-
QString endResult = result.value(QStringLiteral("result")).toString();
183-
if(endResult == QStringLiteral("OK"))
183+
QString endResult = result.value(QLatin1String("result")).toString();
184+
if(endResult == QLatin1String("OK"))
184185
{
185186
QByteArray b64 = QByteArray::fromBase64(
186-
result.value(QStringLiteral("signature")).toObject().value(QStringLiteral("value")).toString().toUtf8());
187+
result.value(QLatin1String("signature")).toObject().value(QLatin1String("value")).toString().toUtf8());
187188
d->signature.assign(b64.cbegin(), b64.cend());
188189
d->hide();
189190
d->l.exit(QDialog::Accepted);
190191
}
191-
else if(endResult == QStringLiteral("NOT_MID_CLIENT") || endResult == QStringLiteral("NOT_FOUND") || endResult == QStringLiteral("NOT_ACTIVE"))
192+
else if(endResult == QLatin1String("NOT_MID_CLIENT") || endResult == QLatin1String("NOT_FOUND") || endResult == QLatin1String("NOT_ACTIVE"))
192193
returnError(tr("User is not a mobile-ID client"));
193-
else if(endResult == QStringLiteral("USER_CANCELLED"))
194+
else if(endResult == QLatin1String("USER_CANCELLED"))
194195
returnError(tr("User denied or cancelled"));
195-
else if(endResult == QStringLiteral("TIMEOUT"))
196+
else if(endResult == QLatin1String("TIMEOUT"))
196197
returnError(tr("Your mobile-ID transaction has expired. Please try again."));
197-
else if(endResult == QStringLiteral("PHONE_ABSENT"))
198+
else if(endResult == QLatin1String("PHONE_ABSENT"))
198199
returnError(tr("Phone is not in coverage area"));
199-
else if(endResult == QStringLiteral("DELIVERY_ERROR"))
200+
else if(endResult == QLatin1String("DELIVERY_ERROR"))
200201
returnError(tr("Request sending error"));
201-
else if(endResult == QStringLiteral("SIM_ERROR"))
202+
else if(endResult == QLatin1String("SIM_ERROR"))
202203
returnError(tr("SIM error"));
203-
else if(endResult == QStringLiteral("SIGNATURE_HASH_MISMATCH"))
204+
else if(endResult == QLatin1String("SIGNATURE_HASH_MISMATCH"))
204205
returnError(tr("Your mobile-ID transaction has failed. Please contact your mobile network operator."));
205206
else
206207
returnError(tr("Service result:") + endResult);
@@ -227,8 +228,8 @@ bool MobileProgress::init(const QString &ssid, const QString &cell)
227228
if(!d->UUID.isEmpty() && QUuid(d->UUID).isNull())
228229
{
229230
WarningDialog::create(d->parentWidget())
230-
->withText(tr("Failed to send request. Check your %1 service access settings.").arg(tr("mobile-ID")))
231231
->withTitle(QCoreApplication::translate("DigiDoc", "Failed to sign container"))
232+
->withText(tr("Failed to send request. Check your %1 service access settings.").arg(tr("mobile-ID")))
232233
->open();
233234
return false;
234235
}

0 commit comments

Comments
 (0)