Skip to content
Snippets Groups Projects
Commit 83d891d1 authored by Martin Straka's avatar Martin Straka
Browse files

Fixed invalid MEP credentials response

parent 0fce2ea0
No related branches found
No related tags found
1 merge request!232Fixed invalid MEP credentials response
This commit is part of merge request !232. Comments created here will be created in the context of that merge request.
......@@ -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.");
......
......@@ -47,6 +47,7 @@ namespace Isds {
enum ErrCode {
ERR_NO_ERROR = 0, /*!< No error, reply is OK. */
ERR_NO_CONNECTION, /*!< No active connection to internet. */
ERR_BAD_REQUEST, /*!< Bad request error. */
ERR_REPLY, /*!< An reply error. */
ERR_SERVER_UNAVAILABLE, /*!< ISDS server is out of service. */
ERR_TIMEOUT, /*!< Connection timed out. */
......
......@@ -71,3 +71,7 @@
#define OTP_ERROR_SEND_QUICKLY "authentication.info.cannotSendQuickly"
#define OTP_ERROR_NOT_SEND "authentication.info.totpNotSended"
#define OTP_ERROR_NOT_ORDERED "authentication.info.totpNotOrdered"
/* ISDS MEP ERROR CODE */
#define MEP_ERROR_USER_NOT_EXISTS "authentication.error.userIsNotExists"
#define MEP_ERROR_USER_NOT_SET "authentication.error.mep.userid.notset"
......@@ -283,7 +283,10 @@ enum Isds::Type::MepResolution waitForMepReply(Isds::Session &session,
logInfoNL("MEP(%i/%i): check response...",
iteration, max_mep_iteration);
timer.stop();
Isds::waitForMep(session, rsCode);
if (Isds::waitForMep(session, rsCode) != Isds::Type::ERR_SUCCESS) {
timer.stop();
return Isds::Type::MR_UNRECOGNISED;
}
timer.start(delay_ms);
}
......@@ -338,6 +341,11 @@ bool Isds::Login::loginMep(Sessions &sessions, const AcntId &acntId,
acntId.username().toUtf8().constData());
errTxt = tr("MEP login was cancelled.");
break;
case Isds::Type::MR_UNRECOGNISED:
logErrorNL("MEP login was failed for '%s'.",
acntId.username().toUtf8().constData());
errTxt = tr("Wrong MEP login credentials. Invalid username or communication code.");
break;
default:
logErrorNL("MEP login failed for '%s'.",
acntId.username().toUtf8().constData());
......
......@@ -40,6 +40,7 @@ enum Isds::Type::Error Isds::errCode2Error(enum Connection::ErrCode errCode) {
case Connection::ERR_TIMEOUT:
return Type::ERR_TIMED_OUT;
break;
case Connection::ERR_BAD_REQUEST:
case Connection::ERR_UNAUTHORIZED:
case Connection::ERR_UNAUTHORIZED_HOTP:
case Connection::ERR_UNAUTHORIZED_TOTP:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment