Skip to content
Snippets Groups Projects

Fixed invalid MEP credentials response

Merged Martin Straka requested to merge fix-mep-login into develop
Viewing commit 83d891d1
Next
Show latest version
5 files
+ 51
2
Preferences
Compare changes
Files
5
+ 36
1
@@ -285,7 +285,25 @@ enum Isds::Connection::ErrCode waitReplyFinished(QNetworkReply *reply)
}
/*!
* @brief Translates response message code into understandable message.
* @brief Translates MEP response message code into understandable message.
*
* @param[in] resCode Response code.
* @return Text message.
*/
static
QString mepErrorDescription(const QByteArray &resCode) {
QString txt = "Unspecified MEP error.";
if (resCode == MEP_ERROR_USER_NOT_EXISTS) {
txt = "Wrong login credentials. Username does not exists.";
} else if (resCode == MEP_ERROR_USER_NOT_SET) {
txt = "Wrong login credentials. Username or valid communication code was not set.";
}
return txt;
}
/*!
* @brief Translates OTP response message code into understandable message.
*
* @param[in] resCode Response code.
* @return Text message.
@@ -351,6 +369,13 @@ enum Isds::Connection::ErrCode processReply(QNetworkReply *reply,
case 303: /* HTTP 303 See Other - redirect */
case 307: /* HTTP 307 Temporary Redirect - redirect */
{
if (!reply->rawHeader("X-Response-message-code").isEmpty()) {
QString errTxt(mepErrorDescription(
reply->rawHeader("X-Response-message-code")));
logDebugLv3NL("MEP authorization warning: %s",
errTxt.toUtf8().constData());
}
/* Store location URL for redirection. */
QVariant possibleRedirectUrl(reply->attribute(
QNetworkRequest::RedirectionTargetAttribute));
@@ -364,6 +389,13 @@ enum Isds::Connection::ErrCode processReply(QNetworkReply *reply,
errCode = Isds::Connection::ERR_NO_ERROR;
}
break;
case 400: /* HTTP 400 Bad Request */
{
logErrorNL("Reply error: %s",
reply->errorString().toUtf8().constData());
errCode = Isds::Connection::ERR_BAD_REQUEST;
}
break;
case 401: /* HTTP 401 Unauthorized */
{
/* Test if some OTP error */
@@ -491,6 +523,9 @@ QString Isds::Connection::errorDescription(enum ErrCode errCode)
case ERR_UNAUTHORIZED_TOTP_SMS:
txt = tr("SMS authorization failed. SMS code couldn't be sent. Your order on premium SMS has been exhausted or cancelled.");
break;
case ERR_BAD_REQUEST:
txt = tr("Authorization failed or bad request due to malformed syntax.");
break;
case ERR_UNSPECIFIED:
default:
txt = tr("An communication error. See log for more detail.");