added editorconfig and formated code
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
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:
1 parent
77a483a38a
commit
e5abe4bb02
23 files changed
+22332
-21478
No files matched your search
@@ -6,7 +6,8 @@
|
||||
#include <syslog.h>
|
||||
|
||||
// function for change user data
|
||||
void change_user(const httplib::Request &request, httplib::Response &response) {
|
||||
void change_user(const httplib::Request& request, httplib::Response& response)
|
||||
{
|
||||
std::cout << GREEN << request.path << RESET << " " << request.method << std::endl;
|
||||
response.set_header("Access-Control-Allow-Origin", "*");
|
||||
if (request.body.empty()) {
|
||||
@@ -54,7 +55,7 @@ void change_user(const httplib::Request &request, httplib::Response &response) {
|
||||
if (json_body["userid"] != nullptr) {
|
||||
changeusruserid = json_body["userid"];
|
||||
nlohmann::json response_user_data = nullptr;
|
||||
for (nlohmann::json &user: all_users) {
|
||||
for (nlohmann::json& user : all_users) {
|
||||
if (user["id"] == userid) {
|
||||
response_user_data = user;
|
||||
}
|
||||
@@ -73,7 +74,7 @@ void change_user(const httplib::Request &request, httplib::Response &response) {
|
||||
|
||||
bool found = false;
|
||||
if (json_body["userid"] != nullptr) {
|
||||
for (nlohmann::basic_json<> &all_user: all_users) {
|
||||
for (nlohmann::basic_json<>& all_user : all_users) {
|
||||
if ((all_user["id"] == changeusruserid)) {
|
||||
if (json_body["username"] != nullptr) { all_user["username"] = json_body["username"]; }
|
||||
if (json_body["password"] != nullptr) { all_user["password"] = json_body["password"]; }
|
||||
@@ -81,18 +82,19 @@ void change_user(const httplib::Request &request, httplib::Response &response) {
|
||||
if (json_body["is_superuser"] != nullptr) { all_user["is_superuser"] = json_body["is_superuser"]; }
|
||||
found = true;
|
||||
std::stringstream syslogstring;
|
||||
syslogstring << "userdata changed for user [" << all_user["username"] << "]";
|
||||
syslogstring << "userdata changed for user [" << all_user["username"] << "]";
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (nlohmann::basic_json<> &all_user: all_users) {
|
||||
}
|
||||
else {
|
||||
for (nlohmann::basic_json<>& all_user : all_users) {
|
||||
if ((all_user["id"] == changeusruserid)) {
|
||||
if (json_body["username"] != nullptr) { all_user["username"] = json_body["username"]; }
|
||||
found = true;
|
||||
std::stringstream syslogstring;
|
||||
syslogstring << "userdata changed for user [" << all_user["username"] << "]";
|
||||
syslogstring << "userdata changed for user [" << all_user["username"] << "]";
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user