mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:47:01 +00:00
refactor/tweaked the error message InvalidChallengeAnswer
This commit is contained in:
parent
82903b525b
commit
2128e4ccd4
@ -552,8 +552,8 @@ object ErrorMessages {
|
||||
val AllowedAttemptsUsedUp = "OBP-40014: Sorry, you've used up your allowed attempts. "
|
||||
val InvalidChallengeType = "OBP-40015: Invalid Challenge Type. Please specify a valid value for CHALLENGE_TYPE, when you create the transaction request."
|
||||
val InvalidChallengeAnswer = s"OBP-40016: Invalid Challenge Answer. Please specify a valid value for answer in Json body. " +
|
||||
s"The challenge answer may be expired(${transactionRequestChallengeTtl} seconds)." +
|
||||
s"Or you've used up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts})." +
|
||||
s"The challenge answer may be expired." +
|
||||
s"Or you've used up your allowed attempts." +
|
||||
"Or if connector = mapped and transactionRequestType_OTP_INSTRUCTION_TRANSPORT = DUMMY and suggested_default_sca_method=DUMMY, the answer must be `123`. " +
|
||||
"Or if connector = others, the challenge answer can be got by phone message or other security ways."
|
||||
val InvalidPhoneNumber = "OBP-40017: Invalid Phone Number. Please specify a valid value for PHONE_NUMBER. Eg:+9722398746 "
|
||||
|
||||
@ -1356,7 +1356,11 @@ object NewStyle extends MdcLoggable{
|
||||
|
||||
def validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String, callContext: Option[CallContext]): OBPReturnType[Boolean] =
|
||||
Connector.connector.vend.validateChallengeAnswer(challengeId: String, hashOfSuppliedAnswer: String, callContext: Option[CallContext]) map { i =>
|
||||
(unboxFullOrFail(i._1, callContext, s"$InvalidChallengeAnswer "), i._2)
|
||||
(unboxFullOrFail(i._1, callContext, s"${
|
||||
InvalidChallengeAnswer
|
||||
.replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).")
|
||||
.replace("up your allowed attempts.", s"up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts} times).")
|
||||
}"), i._2)
|
||||
}
|
||||
|
||||
def allChallengesSuccessfullyAnswered(
|
||||
@ -1399,7 +1403,11 @@ object NewStyle extends MdcLoggable{
|
||||
hashOfSuppliedAnswer: String,
|
||||
callContext: Option[CallContext]
|
||||
) map { i =>
|
||||
(unboxFullOrFail(i._1, callContext, s"$InvalidChallengeAnswer "), i._2)
|
||||
(unboxFullOrFail(i._1, callContext, s"${
|
||||
InvalidChallengeAnswer
|
||||
.replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).")
|
||||
.replace("up your allowed attempts.", s"up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts} times).")
|
||||
}"), i._2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,7 +644,10 @@ trait APIMethods210 {
|
||||
|
||||
(isChallengeAnswerValidated, callContext) <- NewStyle.function.validateChallengeAnswer(challengeAnswerJson.id, challengeAnswerJson.answer, callContext)
|
||||
|
||||
_ <- Helper.booleanToFuture(s"${InvalidChallengeAnswer} ", cc=callContext) {
|
||||
_ <- Helper.booleanToFuture(s"${InvalidChallengeAnswer
|
||||
.replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).")
|
||||
.replace("up your allowed attempts.", s"up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts} times).")
|
||||
} ", cc = callContext) {
|
||||
(isChallengeAnswerValidated == true)
|
||||
}
|
||||
|
||||
|
||||
@ -1630,7 +1630,10 @@ trait APIMethods400 {
|
||||
|
||||
(challengeAnswerIsValidated, callContext) <- NewStyle.function.validateChallengeAnswer(challengeAnswerJson.id, challengeAnswerJson.answer, callContext)
|
||||
|
||||
_ <- Helper.booleanToFuture(s"${InvalidChallengeAnswer.replace("answer may be expired.",s"answer may be expired, current expiration time is ${transactionRequestChallengeTtl} seconds .")} ", cc=callContext) {
|
||||
_ <- Helper.booleanToFuture(s"${InvalidChallengeAnswer
|
||||
.replace("answer may be expired.",s"answer may be expired (${transactionRequestChallengeTtl} seconds).")
|
||||
.replace("up your allowed attempts.",s"up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts} times).")
|
||||
}", cc=callContext) {
|
||||
challengeAnswerIsValidated
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package code.transactionChallenge
|
||||
|
||||
import code.api.util.APIUtil.transactionRequestChallengeTtl
|
||||
import code.api.util.APIUtil.{allowedAnswerTransactionRequestChallengeAttempts, transactionRequestChallengeTtl}
|
||||
import code.api.util.ErrorMessages.InvalidChallengeAnswer
|
||||
import code.api.util.{APIUtil, ErrorMessages}
|
||||
import com.openbankproject.commons.model.{ChallengeTrait, ErrorMessage}
|
||||
import com.openbankproject.commons.model.enums.StrongCustomerAuthentication.SCA
|
||||
@ -77,13 +78,23 @@ object MappedChallengeProvider extends ChallengeProvider {
|
||||
if(currentHashedAnswer==expectedHashedAnswer) {
|
||||
tryo{challenge.mSuccessful(true).mScaStatus(StrongCustomerAuthenticationStatus.finalised.toString).saveMe()}
|
||||
} else {
|
||||
Failure(s"${ErrorMessages.InvalidChallengeAnswer}")
|
||||
Failure(s"${
|
||||
s"${
|
||||
InvalidChallengeAnswer
|
||||
.replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).")
|
||||
.replace("up your allowed attempts.", s"up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts} times).")
|
||||
}"}")
|
||||
}
|
||||
case Some(id) =>
|
||||
if(currentHashedAnswer==expectedHashedAnswer && id==challenge.expectedUserId) {
|
||||
tryo{challenge.mSuccessful(true).mScaStatus(StrongCustomerAuthenticationStatus.finalised.toString).saveMe()}
|
||||
} else {
|
||||
Failure(s"${ErrorMessages.InvalidChallengeAnswer}")
|
||||
Failure(s"${
|
||||
s"${
|
||||
InvalidChallengeAnswer
|
||||
.replace("answer may be expired.", s"answer may be expired (${transactionRequestChallengeTtl} seconds).")
|
||||
.replace("up your allowed attempts.", s"up your allowed attempts (${allowedAnswerTransactionRequestChallengeAttempts} times).")
|
||||
}"}")
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user