Line data Source code
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_by_serial.h"
30 :
31 :
32 : enum MHD_Result
33 1 : 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 1 : struct TMH_MerchantInstance *mi = hc->instance;
39 : enum GNUNET_DB_QueryStatus qs;
40 : unsigned long long serial;
41 : char dummy;
42 :
43 1 : GNUNET_assert (NULL != mi);
44 1 : GNUNET_assert (NULL != hc->infix);
45 1 : if (1 != sscanf (hc->infix,
46 : "%llu%c",
47 : &serial,
48 : &dummy))
49 : {
50 0 : GNUNET_break_op (0);
51 0 : 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 1 : qs = TALER_MERCHANTDB_delete_login_token_by_serial (TMH_db,
59 1 : mi->settings.id,
60 : serial);
61 1 : switch (qs)
62 : {
63 0 : case GNUNET_DB_STATUS_HARD_ERROR:
64 : case GNUNET_DB_STATUS_SOFT_ERROR:
65 0 : GNUNET_break (0);
66 0 : return TALER_MHD_reply_with_ec (connection,
67 : TALER_EC_GENERIC_DB_STORE_FAILED,
68 : "delete_login_token_by_serial");
69 0 : case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
70 0 : return TALER_MHD_reply_with_error (
71 : connection,
72 : MHD_HTTP_NOT_FOUND,
73 : TALER_EC_MERCHANT_GENERIC_ACCESS_TOKEN_UNKNOWN,
74 0 : hc->infix);
75 1 : case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
76 1 : return TALER_MHD_reply_static (connection,
77 : MHD_HTTP_NO_CONTENT,
78 : NULL,
79 : NULL,
80 : 0);
81 : }
82 0 : GNUNET_break (0);
83 0 : return MHD_NO;
84 : }
85 :
86 :
87 : /* end of taler-merchant-httpd_delete-private-tokens-SERIAL.c */
|