From e9c63cf3194aacb950026bec8ff2201f1d1f5418 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 6 Apr 2022 14:32:53 +0200 Subject: fix #7218 and #7219 --- src/backend/anastasis-httpd_truth-challenge.c | 9 ++++---- src/include/anastasis.h | 5 +++++ src/include/anastasis_service.h | 6 ++++++ src/lib/anastasis_recovery.c | 3 +++ src/reducer/anastasis_api_recovery_redux.c | 29 ++++++++++++++++++++++++++ src/restclient/anastasis_api_truth_challenge.c | 6 ++++++ src/testing/testing_api_cmd_truth_challenge.c | 2 ++ src/testing/testing_cmd_challenge_answer.c | 3 +++ 8 files changed, 59 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/backend/anastasis-httpd_truth-challenge.c b/src/backend/anastasis-httpd_truth-challenge.c index b03c883..98ae524 100644 --- a/src/backend/anastasis-httpd_truth-challenge.c +++ b/src/backend/anastasis-httpd_truth-challenge.c @@ -1295,10 +1295,11 @@ AH_handler_truth_challenge ( { /* Too early for a retransmission! */ GNUNET_free (decrypted_truth); - return TALER_MHD_reply_with_error (gc->connection, - MHD_HTTP_ALREADY_REPORTED, - TALER_EC_ANASTASIS_TRUTH_CHALLENGE_ACTIVE, - NULL); + return TALER_MHD_REPLY_JSON_PACK ( + gc->connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_string ("challenge_type", + "TAN_ALREADY_SENT")); } } diff --git a/src/include/anastasis.h b/src/include/anastasis.h index 90f3f5d..473756f 100644 --- a/src/include/anastasis.h +++ b/src/include/anastasis.h @@ -125,6 +125,11 @@ enum ANASTASIS_ChallengeStartStatus */ ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED, + /** + * A TAN has been sent before. + */ + ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT, + /** * Wire transfer required, banking details provided. */ diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h index e88b7e0..8af0f07 100644 --- a/src/include/anastasis_service.h +++ b/src/include/anastasis_service.h @@ -595,6 +595,12 @@ enum ANASTASIS_ChallengeDetailType */ ANASTASIS_CS_TAN_SENT, + /** + * A challenge TAN was already recently sent to the customer. + * A hint may be provided as to the address used. + */ + ANASTASIS_CS_TAN_ALREADY_SENT, + /** * The customer should wire funds to the bank * account address provided. diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c index b70061d..c425398 100644 --- a/src/lib/anastasis_recovery.c +++ b/src/lib/anastasis_recovery.c @@ -286,6 +286,9 @@ truth_challenge_cb (void *cls, csr.details.tan_address_hint = tcd->details.success.details.tan_address_hint; break; + case ANASTASIS_CS_TAN_ALREADY_SENT: + csr.cs = ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT; + break; case ANASTASIS_CS_WIRE_FUNDS: csr.cs = ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED; csr.details.bank_transfer_required diff --git a/src/reducer/anastasis_api_recovery_redux.c b/src/reducer/anastasis_api_recovery_redux.c index e08c7e7..a8083f2 100644 --- a/src/reducer/anastasis_api_recovery_redux.c +++ b/src/reducer/anastasis_api_recovery_redux.c @@ -593,6 +593,35 @@ start_feedback_cb ( sctx->state); sctx_free (sctx); return; + + case ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT: + { + json_t *instructions; + char *hint; + + GNUNET_asprintf (&hint, + _ ("TAN code already sent.")); + instructions = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("state", + "send-to-address"), + GNUNET_JSON_pack_string ("display_hint", + hint), + GNUNET_JSON_pack_uint64 ("http_status", + (json_int_t) csr->http_status)); + GNUNET_free (hint); + GNUNET_assert (0 == + json_object_set_new (feedback, + uuid, + instructions)); + } + set_state (sctx->state, + ANASTASIS_RECOVERY_STATE_CHALLENGE_SOLVING); + sctx->cb (sctx->cb_cls, + TALER_EC_NONE, + sctx->state); + sctx_free (sctx); + return; + case ANASTASIS_CHALLENGE_START_STATUS_PAYMENT_REQUIRED: { json_t *pay; diff --git a/src/restclient/anastasis_api_truth_challenge.c b/src/restclient/anastasis_api_truth_challenge.c index 76e9ec5..606bcfb 100644 --- a/src/restclient/anastasis_api_truth_challenge.c +++ b/src/restclient/anastasis_api_truth_challenge.c @@ -161,6 +161,12 @@ handle_truth_challenge_finished (void *cls, tcd.details.success.details.tan_address_hint = tan_hint; break; } + if (0 == strcmp (ct, + "TAN_ALREADY_SENT")) + { + tcd.details.success.cs = ANASTASIS_CS_TAN_ALREADY_SENT; + break; + } if ( (0 == strcmp (ct, "FILE_WRITTEN")) && (NULL != filename) ) diff --git a/src/testing/testing_api_cmd_truth_challenge.c b/src/testing/testing_api_cmd_truth_challenge.c index c584d5f..f1384c4 100644 --- a/src/testing/testing_api_cmd_truth_challenge.c +++ b/src/testing/testing_api_cmd_truth_challenge.c @@ -153,6 +153,8 @@ truth_challenge_cb (void *cls, ksls->instructions = GNUNET_strdup ( tcd->details.success.details.tan_address_hint); break; + case ANASTASIS_CS_TAN_ALREADY_SENT: + break; case ANASTASIS_CS_WIRE_FUNDS: /* FIXME: not implemented */ GNUNET_break (0); diff --git a/src/testing/testing_cmd_challenge_answer.c b/src/testing/testing_cmd_challenge_answer.c index 88c4c2f..3472793 100644 --- a/src/testing/testing_cmd_challenge_answer.c +++ b/src/testing/testing_cmd_challenge_answer.c @@ -370,6 +370,9 @@ challenge_start_cb (void *af_cls, case ANASTASIS_CHALLENGE_START_STATUS_TAN_SENT_HINT_PROVIDED: GNUNET_break (0); /* FIXME: not implemented */ break; + case ANASTASIS_CHALLENGE_START_STATUS_TAN_ALREADY_SENT: + GNUNET_break (0); /* FIXME: not implemented */ + break; case ANASTASIS_CHALLENGE_START_STATUS_BANK_TRANSFER_REQUIRED: GNUNET_break (0); /* FIXME: not implemented */ break; -- cgit v1.2.3