diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2023-07-23 21:18:32 +0200 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2023-07-23 21:18:32 +0200 |
commit | 5bf90c3505130bb92d518e8ae489d55095cb1cf3 (patch) | |
tree | 27bd1a47fd29043c4472e26505d213dbc103e284 /src/exchange | |
parent | e230eaad76f4488dc1b5dbc0aba6ab26b9423e75 (diff) |
kyc logic with birthdate setting test added
1. Added age-requirement check in withdraw-handler (like in batch-withdraw)
2. In test_exchange_api_age_restriction:
- kyc-oauth2 started, with static birthdate in answers
- withdraw triggers kyc
- second withdraw fails due to age restriction requirements
Diffstat (limited to 'src/exchange')
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index cbc64141..07fcc846 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -26,6 +26,7 @@ #include "platform.h" #include <gnunet/gnunet_util_lib.h> #include <jansson.h> +#include "taler-exchange-httpd.h" #include "taler_json_lib.h" #include "taler_kyclogic_lib.h" #include "taler_mhd_lib.h" @@ -180,6 +181,8 @@ withdraw_transaction (void *cls, bool found = false; bool balance_ok = false; bool nonce_ok = false; + bool age_ok = false; + uint16_t allowed_maximum_age = 0; uint64_t ruuid; const struct TALER_CsNonce *nonce; const struct TALER_BlindedPlanchet *bp; @@ -342,9 +345,12 @@ withdraw_transaction (void *cls, nonce, &wc->collectable, wc->now, + TEH_age_restriction_enabled, &found, &balance_ok, &nonce_ok, + &age_ok, + &allowed_maximum_age, &ruuid); if (0 > qs) { @@ -366,6 +372,20 @@ withdraw_transaction (void *cls, NULL); return GNUNET_DB_STATUS_HARD_ERROR; } + if (! age_ok) + { + /* We respond with the lowest age in the corresponding age group + * of the required age */ + uint16_t lowest_age = TALER_get_lowest_age ( + &TEH_age_restriction_config.mask, + allowed_maximum_age); + + TEH_plugin->rollback (TEH_plugin->cls); + *mhd_ret = TEH_RESPONSE_reply_reserve_age_restriction_required ( + connection, + lowest_age); + return GNUNET_DB_STATUS_HARD_ERROR; + } if (! balance_ok) { TEH_plugin->rollback (TEH_plugin->cls); |