updated tests and fix some errors
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Failing after 13s
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
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Failing after 13s
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:
1 parent
86739af751
commit
194d12e010
4 files changed
+357
No files matched your search
@@ -36,6 +36,7 @@ bool db_delete_user(const int id) {
|
||||
printf("User deleted successfully. ID: %d\n", id);
|
||||
} else {
|
||||
printf("No user found with ID: %d\n", id);
|
||||
pthread_mutex_unlock(&db_mutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,16 @@
|
||||
#include "utils.h"
|
||||
|
||||
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"));
|
||||
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));
|
||||
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"),
|
||||
@@ -18,4 +27,5 @@ 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);
|
||||
cJSON_Delete(payload);
|
||||
}
|
||||
@@ -3,7 +3,16 @@
|
||||
#include "utils.h"
|
||||
|
||||
void get_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"));
|
||||
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));
|
||||
return;
|
||||
}
|
||||
if (!jwt_verifyJWT(requestdata->token, JWT_DEFAULT_SECRET)) {
|
||||
free_request_with_token(requestdata);
|
||||
mg_http_reply(c, 403, "Content-Type: application/json\r\n", "{%m:%m}", MG_ESC("error"),
|
||||
|
||||
Reference in new issue
Block a user