taler-merchant-httpd_delete-private-tokens-SERIAL.c (2849B)
1 /* 2 This file is part of GNU Taler 3 (C) 2023 Taler Systems SA 4 5 GNU Taler is free software; you can redistribute it and/or modify 6 it under the terms of the GNU Affero General Public License as 7 published by the Free Software Foundation; either version 3, 8 or (at your option) any later version. 9 10 GNU Taler is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public 16 License along with TALER; see the file COPYING. If not, 17 see <http://www.gnu.org/licenses/> 18 */ 19 20 /** 21 * @file taler-merchant-httpd_delete-private-tokens-SERIAL.c 22 * @brief implementing DELETE /instances/$ID/token request handling 23 * @author Christian Grothoff 24 */ 25 #include "taler/platform.h" 26 #include "taler-merchant-httpd_delete-private-tokens-SERIAL.h" 27 #include "taler-merchant-httpd_helper.h" 28 #include <taler/taler_json_lib.h> 29 30 31 MHD_RESULT 32 TMH_private_delete_instances_ID_token_SERIAL ( 33 const struct TMH_RequestHandler *rh, 34 struct MHD_Connection *connection, 35 struct TMH_HandlerContext *hc) 36 { 37 struct TMH_MerchantInstance *mi = hc->instance; 38 enum GNUNET_DB_QueryStatus qs; 39 unsigned long long serial; 40 char dummy; 41 42 GNUNET_assert (NULL != mi); 43 GNUNET_assert (NULL != hc->infix); 44 if (1 != sscanf (hc->infix, 45 "%llu%c", 46 &serial, 47 &dummy)) 48 { 49 GNUNET_break_op (0); 50 return TALER_MHD_reply_with_error (connection, 51 MHD_HTTP_BAD_REQUEST, 52 TALER_EC_GENERIC_PARAMETER_MALFORMED, 53 "serial must be a number"); 54 } 55 56 57 qs = TMH_db->delete_login_token_serial (TMH_db->cls, 58 mi->settings.id, 59 serial); 60 switch (qs) 61 { 62 case GNUNET_DB_STATUS_HARD_ERROR: 63 case GNUNET_DB_STATUS_SOFT_ERROR: 64 GNUNET_break (0); 65 return TALER_MHD_reply_with_ec (connection, 66 TALER_EC_GENERIC_DB_STORE_FAILED, 67 "delete_login_token_by_serial"); 68 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 69 return TALER_MHD_reply_with_error ( 70 connection, 71 MHD_HTTP_NOT_FOUND, 72 TALER_EC_MERCHANT_GENERIC_ACCESS_TOKEN_UNKNOWN, 73 hc->infix); 74 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 75 return TALER_MHD_reply_static (connection, 76 MHD_HTTP_NO_CONTENT, 77 NULL, 78 NULL, 79 0); 80 } 81 GNUNET_break (0); 82 return MHD_NO; 83 } 84 85 86 /* end of taler-merchant-httpd_delete-private-tokens-SERIAL.c */