updated and added more funcs to be small
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Make (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-CMake (push) Has been cancelled
Prepare Build and Testing executable binary / Prepare-Build-Testing-With-Meson (push) Has been cancelled

This commit is contained in:
wt committed 2025-04-19 17:03:56 +07:00
1 parent 11028cb567
commit 782315b9f4
8 files changed
+29 -77

No files matched your search

+3 -11
View File
@@ -3,6 +3,7 @@
#include <colors.h>
#include <types.hpp>
#include <auth/auth.hpp>
#include <helpers.hpp>
namespace api
{
@@ -12,18 +13,9 @@ namespace api
{
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
response.set_header("Access-Control-Allow-Origin", "*");
if (request.body.empty())
{
response.set_content(ACCESS_REQUIRED_STRING, JSON_TYPE);
return;
}
check_body_empty(request, response, ACCESS_REQUIRED_STRING);
nlohmann::json json_body = nlohmann::json::parse(request.body);
if (json_body["token"] == nullptr)
{
response.set_content(ACCESS_REQUIRED_STRING, JSON_TYPE);
return;
}
check_body_data(json_body, "token", response, ACCESS_REQUIRED_STRING);
if (authenticate(json_body["token"]))
{
+3 -10
View File
@@ -6,6 +6,7 @@
#include <iostream>
#include <json.hpp>
#include <pthread.h>
#include <helpers.hpp>
#define DEFAULT_TMP_FILE_NAME "/tmp/image"
#define DEFAULT_DST_FILE_NAME "/images/image"
@@ -68,17 +69,9 @@ namespace api
{
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
response.set_header("Access-Control-Allow-Origin", "*");
if (request.body.empty())
{
response.set_content(ACCESS_REQUIRED_STRING, JSON_TYPE);
return;
}
check_body_empty(request, response, ACCESS_REQUIRED_STRING);
nlohmann::json json_body = nlohmann::json::parse(request.body);
if (json_body["token"] == nullptr)
{
response.set_content(ACCESS_REQUIRED_STRING, JSON_TYPE);
return;
}
check_body_data(json_body, "token", response, ACCESS_REQUIRED_STRING);
if (!authenticate(json_body["token"]))
{
response.set_content(R"({"access":"reject"})", JSON_TYPE);