taler-merchant-httpd_delete-private-tokens-SERIAL.c (2932B)
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 src/backend/taler-merchant-httpd_delete-private-tokens-SERIAL.c 22 * @brief implementing DELETE /instances/$ID/token request handling 23 * @author Christian Grothoff 24 */ 25 #include "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 #include "merchant-database/delete_login_token.h" 30 31 32 enum MHD_Result 33 TMH_private_delete_instances_ID_token_SERIAL ( 34 const struct TMH_RequestHandler *rh, 35 struct MHD_Connection *connection, 36 struct TMH_HandlerContext *hc) 37 { 38 struct TMH_MerchantInstance *mi = hc->instance; 39 enum GNUNET_DB_QueryStatus qs; 40 unsigned long long serial; 41 char dummy; 42 43 GNUNET_assert (NULL != mi); 44 GNUNET_assert (NULL != hc->infix); 45 if (1 != sscanf (hc->infix, 46 "%llu%c", 47 &serial, 48 &dummy)) 49 { 50 GNUNET_break_op (0); 51 return TALER_MHD_reply_with_error (connection, 52 MHD_HTTP_BAD_REQUEST, 53 TALER_EC_GENERIC_PARAMETER_MALFORMED, 54 "serial must be a number"); 55 } 56 57 58 qs = TALER_MERCHANTDB_delete_login_token_serial (TMH_db, 59 mi->settings.id, 60 serial); 61 switch (qs) 62 { 63 case GNUNET_DB_STATUS_HARD_ERROR: 64 case GNUNET_DB_STATUS_SOFT_ERROR: 65 GNUNET_break (0); 66 return TALER_MHD_reply_with_ec (connection, 67 TALER_EC_GENERIC_DB_STORE_FAILED, 68 "delete_login_token_by_serial"); 69 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 70 return TALER_MHD_reply_with_error ( 71 connection, 72 MHD_HTTP_NOT_FOUND, 73 TALER_EC_MERCHANT_GENERIC_ACCESS_TOKEN_UNKNOWN, 74 hc->infix); 75 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 76 return TALER_MHD_reply_static (connection, 77 MHD_HTTP_NO_CONTENT, 78 NULL, 79 NULL, 80 0); 81 } 82 GNUNET_break (0); 83 return MHD_NO; 84 } 85 86 87 /* end of taler-merchant-httpd_delete-private-tokens-SERIAL.c */