added HTTP_HEADERS constant and tls support
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 13s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 15s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 8s

This commit is contained in:
wt committed 2025-08-29 18:28:10 +07:00
1 parent 4c7a156723
commit e0bd40e47f
13 files changed
+78 -64

No files matched your search

+3 -3
View File
@@ -5,14 +5,14 @@
void verify_token(struct mg_connection *c, struct mg_http_message *hm) {
const request_with_token *data = check_body(hm);
if (data->error != nullptr) {
mg_http_reply(c, 403, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n", "{%m:%m}", MG_ESC("error"), MG_ESC(data->error));
mg_http_reply(c, 403, HTTP_HEADERS, "{%m:%m}", MG_ESC("error"), MG_ESC(data->error));
return;
}
const bool valid = jwt_verifyJWT(data->token, JWT_DEFAULT_SECRET);
if (!valid) {
mg_http_reply(c, 403, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n", "{%m:%m}", MG_ESC("error"),
mg_http_reply(c, 403, HTTP_HEADERS, "{%m:%m}", MG_ESC("error"),
MG_ESC("invalid token"));
return;
}
mg_http_reply(c, 200, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n", "{%m:true}", MG_ESC("valid"));
mg_http_reply(c, 200, HTTP_HEADERS, "{%m:true}", MG_ESC("valid"));
}