Files
openrouter/src/auth/auth.cpp
T
wt 4b2d425d13
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
added backup restore settings and updated config #3
2025-02-21 12:23:24 +07:00

25 lines
660 B
C++

#include <auth/auth.hpp>
#include <httplib.h>
#include <json.hpp>
#include <types.hpp>
#include <config/config.hpp>
bool authenticate(const std::string &token)
{
httplib::Client cli(config::config.getConfig()["auth_service"]);
std::string body = R"({"token":")" + token + R"("})";
// body << R"({"token":")" << token << R"("})";
httplib::Result res = cli.Post("/api/access", body, JSON_TYPE);
if (res->status == httplib::OK_200)
{
nlohmann::json resjson = nlohmann::json::parse(res->body);
if (resjson["access"] == "reject")
{
return false;
}
return true;
}
return false;
}