diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-09-06 20:16:03 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-09-06 20:16:21 +0200 |
commit | 5e2b19c64e2e8a3b84d82f1cf5c3c088e01b5c0c (patch) | |
tree | f221655cb82a870dc0ac467ce3ae5a187360c180 /src/backend | |
parent | 68bc1dd88a4de48736c289e0ed5871f4cb72a908 (diff) | |
download | merchant-5e2b19c64e2e8a3b84d82f1cf5c3c088e01b5c0c.tar.gz merchant-5e2b19c64e2e8a3b84d82f1cf5c3c088e01b5c0c.tar.bz2 merchant-5e2b19c64e2e8a3b84d82f1cf5c3c088e01b5c0c.zip |
fix #7936
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-account.c | 43 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-instances.c | 12 |
3 files changed, 49 insertions, 8 deletions
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index 30d84751..6e9d8793 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -456,7 +456,7 @@ struct TMH_RequestHandler /** * Required authentication scope for this request. NONE implies that - * #TMH_AS_ALL is required unless this is a #MHD_HTTP_GET method, in which + * #TMH_AS_ALL is required unless this is a #MHD_HTTP_METHOD_GET method, in which * case #TMH_AS_READ_ONLY is sufficient. */ enum TMH_AuthScope auth_scope; diff --git a/src/backend/taler-merchant-httpd_private-post-account.c b/src/backend/taler-merchant-httpd_private-post-account.c index 73abfe48..6ad3902d 100644 --- a/src/backend/taler-merchant-httpd_private-post-account.c +++ b/src/backend/taler-merchant-httpd_private-post-account.c @@ -139,6 +139,49 @@ TMH_private_post_account (const struct TMH_RequestHandler *rh, break; case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: /* conflict: account exists */ + { + struct TALER_MERCHANTDB_AccountDetails adx; + + qs = TMH_db->select_account_by_uri (TMH_db->cls, + mi->settings.id, + ad.payto_uri, + &adx); + switch (qs) + { + case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: + if ( (0 == strcmp (adx.payto_uri, + ad.payto_uri) ) && + ( (adx.credit_facade_credentials == + ad.credit_facade_credentials) || + (1 == json_equal (adx.credit_facade_credentials, + ad.credit_facade_credentials)) ) && + ( (adx.credit_facade_url == ad.credit_facade_url) || + ( (NULL != adx.credit_facade_url) && + (NULL != ad.credit_facade_url) && + (0 == strcmp (adx.credit_facade_url, + ad.credit_facade_url)) ) ) ) + { + TMH_wire_method_free (wm); + GNUNET_free (adx.payto_uri); + return TALER_MHD_REPLY_JSON_PACK (connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_data_auto ("salt", + &adx.salt), + GNUNET_JSON_pack_data_auto ("h_wire", + &adx.h_wire)); + } + break; + case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: + case GNUNET_DB_STATUS_SOFT_ERROR: + case GNUNET_DB_STATUS_HARD_ERROR: + GNUNET_break (0); + TMH_wire_method_free (wm); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "select_account"); + } + } TMH_wire_method_free (wm); return TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 398a846d..bc87ab41 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -237,13 +237,10 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, NULL, 0); } - else - { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_CONFLICT, - TALER_EC_MERCHANT_PRIVATE_POST_INSTANCES_ALREADY_EXISTS, - is.id); - } + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_CONFLICT, + TALER_EC_MERCHANT_PRIVATE_POST_INSTANCES_ALREADY_EXISTS, + is.id); } } @@ -314,6 +311,7 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, TMH_db->rollback (TMH_db->cls); if (GNUNET_DB_STATUS_SOFT_ERROR == qs) goto retry; + GNUNET_break (0); // FIXME: distinguish better by qs ret = TALER_MHD_reply_with_error (connection, MHD_HTTP_CONFLICT, TALER_EC_MERCHANT_PRIVATE_POST_INSTANCES_ALREADY_EXISTS, |