added cors headers and colors log
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 10s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 21s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 8s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Successful in 10s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Successful in 21s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 8s
This commit is contained in:
1 parent
5840fded28
commit
28655e7b46
13 files changed
+160
-56
No files matched your search
+5
-5
@@ -4,18 +4,18 @@
|
||||
|
||||
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_http_reply(c, 400, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\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\nAccess-Control-Allow-Origin: *\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"),
|
||||
mg_http_reply(c, 403, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n", "{%m:%m}", MG_ESC("error"),
|
||||
MG_ESC("invalid token"));
|
||||
return;
|
||||
}
|
||||
@@ -27,7 +27,7 @@ void get_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
free_request_with_token(requestdata);
|
||||
cJSON_Delete(payload);
|
||||
free(username);
|
||||
mg_http_reply(c, 404, "Content-Type: application/json\r\n", "{%m:%m}", MG_ESC("error"),
|
||||
mg_http_reply(c, 404, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n", "{%m:%m}", MG_ESC("error"),
|
||||
MG_ESC("user not found"));
|
||||
return;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ void get_user(struct mg_connection *c, struct mg_http_message *hm) {
|
||||
user->id, user->username, user->email, user->group,
|
||||
user->is_superuser ? "true" : "false");
|
||||
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n", responsedata);
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\nAccess-Control-Allow-Origin: *\r\n", responsedata);
|
||||
free_request_with_token(requestdata);
|
||||
free(username);
|
||||
free_user(user);
|
||||
|
||||
Reference in new issue
Block a user