update added to config.json jwt_secret
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Failing after 10s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Failing after 14s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Failing after 12s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make-Without-sqlite3 (push) Failing after 9s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake-Without-sqlite3 (push) Failing after 14s
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson-Without-sqlite3 (push) Failing after 13s

This commit is contained in:
wt
2026-03-10 16:40:33 +07:00
parent e4efaa6165
commit e0c807bb35
9 changed files with 80 additions and 9 deletions
+9 -1
View File
@@ -1,6 +1,7 @@
#include "security/jwt.h"
#include "user.h"
#include "utils/utils.h"
#include "config/config.h"
void change_user(struct mg_connection *c, struct mg_http_message *hm) {
if (hm->body.len == 0) {
@@ -14,7 +15,14 @@ void change_user(struct mg_connection *c, struct mg_http_message *hm) {
MG_ESC(requestdata->error));
return;
}
const bool valid = jwt_verifyJWT(requestdata->token, JWT_DEFAULT_SECRET);
char *jwt_secret = cm_get_parameter_as_string(config, "jwt_secret");
bool valid = false;
if (jwt_secret) {
printf("jwt_secret is not null %s\n", jwt_secret);
valid = jwt_verifyJWT(requestdata->token, jwt_secret);
} else {
valid = jwt_verifyJWT(requestdata->token, JWT_DEFAULT_SECRET);
}
if (!valid) {
mg_http_reply(c, 403, HTTP_HEADERS, "{%m:%m}", MG_ESC("error"),
MG_ESC("invalid token"));