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
28 lines
885 B
C++
28 lines
885 B
C++
#include <system/reboot/reboot.hpp>
|
|
#include <json.hpp>
|
|
#include <colors.h>
|
|
#include <types.hpp>
|
|
#include <auth/auth.hpp>
|
|
#include <helpers.hpp>
|
|
|
|
namespace api
|
|
{
|
|
namespace system
|
|
{
|
|
void reboot(const httplib::Request& request, httplib::Response& response)
|
|
{
|
|
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
|
|
response.set_header("Access-Control-Allow-Origin", "*");
|
|
check_body_empty(request, response, ACCESS_REQUIRED_STRING);
|
|
nlohmann::json json_body = nlohmann::json::parse(request.body);
|
|
check_body_data(json_body, "token", response, ACCESS_REQUIRED_STRING);
|
|
|
|
if (authenticate(json_body["token"]))
|
|
{
|
|
std::system("reboot");
|
|
}
|
|
response.set_content(R"({"access":"reject"})", JSON_TYPE);
|
|
}
|
|
}
|
|
}
|