update challenge modules aginst spec
Change-Id: Ibcfe851a77df1854f417d60cd48a66f8213aedc6
diff --git a/src/challenge-modules/challenge-email.cpp b/src/challenge-modules/challenge-email.cpp
index c12ba88..d98972f 100644
--- a/src/challenge-modules/challenge-email.cpp
+++ b/src/challenge-modules/challenge-email.cpp
@@ -29,16 +29,15 @@
const std::string ChallengeEmail::NEED_CODE = "need-code";
const std::string ChallengeEmail::WRONG_CODE = "wrong-code";
+const std::string ChallengeEmail::INVALID_EMAIL = "invalid-email";
const std::string ChallengeEmail::PARAMETER_KEY_EMAIL = "email";
const std::string ChallengeEmail::PARAMETER_KEY_CODE = "code";
ChallengeEmail::ChallengeEmail(const std::string& scriptPath,
const size_t& maxAttemptTimes,
const time::seconds secretLifetime)
- : ChallengeModule("email")
+ : ChallengeModule("email", maxAttemptTimes, secretLifetime)
, m_sendEmailScript(scriptPath)
- , m_maxAttemptTimes(maxAttemptTimes)
- , m_secretLifetime(secretLifetime)
{
}
@@ -52,7 +51,7 @@
// for the first time, init the challenge
std::string emailAddress = readString(params.get(tlv_parameter_value));
if (!isValidEmailAddress(emailAddress)) {
- return returnWithError(request, ErrorCode::INVALID_PARAMETER, "Invalid email address format.");
+ return returnWithNewChallengeStatus(request, INVALID_EMAIL, JsonSection(), m_maxAttemptTimes - 1, m_secretLifetime);
}
auto lastComponentRequested = readString(request.m_cert.getIdentity().get(-1));
if (lastComponentRequested != emailAddress) {