hot fix
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Failing after 12s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Failing after 10s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 10s

This commit is contained in:
wt committed 2025-08-27 13:33:15 +07:00
1 parent 194d12e010
commit 604363a577
2 files changed
+12 -5

No files matched your search

+9 -5
View File
@@ -4,19 +4,22 @@
void delete_user(struct mg_connection *c, struct mg_http_message *hm) {
if (hm->body.len == 0) {
mg_http_reply(c, 400, "Content-Type: application/json\r\n", "{%m:%m}", MG_ESC("error"),
MG_ESC("must have token"));
mg_http_reply(c, 400, "Content-Type: application/json\r\n", "{%m:%m}",
MG_ESC("error"), MG_ESC("must have token"));
return;
}
request_with_token *requestdata = check_body(hm);
if (requestdata->error != NULL) {
mg_http_reply(c, 403, "Content-Type: application/json\r\n", "{%m:%m}", MG_ESC("error"), MG_ESC(requestdata->error));
mg_http_reply(c, 403, "Content-Type: application/json\r\n", "{%m:%m}",
MG_ESC("error"), MG_ESC(requestdata->error));
// free_request_with_token(requestdata);
return;
}
const bool valid = jwt_verifyJWT(requestdata->token, JWT_DEFAULT_SECRET);
if (!valid) {
mg_http_reply(c, 403, "Content-Type: application/json\r\n", "{%m:%m}", MG_ESC("error"),
MG_ESC("invalid token"));
mg_http_reply(c, 403, "Content-Type: application/json\r\n", "{%m:%m}",
MG_ESC("error"), MG_ESC("invalid token"));
free_request_with_token(requestdata);
return;
}
cJSON *payload = jwt_get_payload(requestdata->token);
@@ -27,5 +30,6 @@ void delete_user(struct mg_connection *c, struct mg_http_message *hm) {
user_deleted ? "true" : "false");
mg_http_reply(c, 200, "Content-Type: application/json\r\n", responsedata);
free_request_with_token(requestdata);
cJSON_Delete(payload);
}
+3
View File
@@ -12,6 +12,9 @@ request_with_token *new_request_with_token(char *token, cJSON *body,
}
void free_request_with_token(request_with_token *data) {
if (!data) {
return;
}
if (data->body != nullptr) {
cJSON_Delete(data->body);
}