deleted stringstream
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:
@@ -3,3 +3,4 @@ bin
|
||||
.vscode
|
||||
.idea
|
||||
cmake-build-debug
|
||||
.cache
|
||||
|
||||
@@ -94,14 +94,12 @@ void add_user(const httplib::Request& request, httplib::Response& response)
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream new_user_data;
|
||||
|
||||
new_user_data << R"({"id":")" << get_random_string(ALPHABET, 50) << R"(","username":")"
|
||||
<< username << R"(","password":")" << password << R"(","group":)";
|
||||
(json_body["group"] != nullptr) ? new_user_data << json_body["group"] : new_user_data << "\"users\"";
|
||||
new_user_data << ",\"is_superuser\":";
|
||||
(json_body["is_superuser"] != nullptr) ? new_user_data << json_body["is_superuser"] : new_user_data << "\"0\"";
|
||||
new_user_data << "}";
|
||||
std::string new_user_data;
|
||||
new_user_data += R"({"id":")" + get_random_string(ALPHABET, 50) + R"(","username":")" + username + R"(","password":")" + password + R"(","group":)";
|
||||
(json_body["group"] != nullptr) ? new_user_data += R"(")" + std::string(json_body["group"]) + R"(")" : new_user_data += R"("users")";
|
||||
new_user_data += ",\"is_superuser\":";
|
||||
(json_body["is_superuser"] != nullptr) ? new_user_data += R"(")" + std::string(json_body["is_superuser"]) + R"(")" : new_user_data += "\"0\"";
|
||||
new_user_data += "}";
|
||||
all_users.push_back(nlohmann::json::parse(new_user_data));
|
||||
|
||||
std::ofstream usersfilew(USERS_FILE);
|
||||
|
||||
@@ -90,9 +90,8 @@ void change_password(const httplib::Request& request, httplib::Response& respons
|
||||
if ((all_user["id"] == changepassuserid)) {
|
||||
all_user["password"] = new_password;
|
||||
found = true;
|
||||
std::stringstream syslogstring;
|
||||
syslogstring << "password changed for user [" << all_user["username"] << "]";
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
std::string syslogstring = "password changed for user [" + std::string(all_user["username"]) + "]";
|
||||
syslog(LOG_INFO, syslogstring.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -102,9 +101,8 @@ void change_password(const httplib::Request& request, httplib::Response& respons
|
||||
if ((all_user["id"] == changepassuserid) && (all_user["password"] == old_password)) {
|
||||
all_user["password"] = new_password;
|
||||
found = true;
|
||||
std::stringstream syslogstring;
|
||||
syslogstring << "password changed for user [" << all_user["username"] << "]";
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
std::string syslogstring = "password changed for user [" + std::string(all_user["username"]) + "]";
|
||||
syslog(LOG_INFO, syslogstring.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,9 +81,8 @@ void change_user(const httplib::Request& request, httplib::Response& response)
|
||||
if (json_body["group"] != nullptr) { all_user["group"] = json_body["group"]; }
|
||||
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"] << "]";
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
std::string syslogstring = "userdata changed for user [" + std::string(all_user["username"]) + "]";
|
||||
syslog(LOG_INFO, syslogstring.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -93,9 +92,8 @@ void change_user(const httplib::Request& request, httplib::Response& response)
|
||||
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"] << "]";
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
std::string syslogstring = "userdata changed for user [" + std::string(all_user["username"]) + "]";
|
||||
syslog(LOG_INFO, syslogstring.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,11 +67,10 @@ void delete_user(const httplib::Request& request, httplib::Response& response)
|
||||
bool found = false;
|
||||
for (size_t i = 0; i < all_users.size(); i++) {
|
||||
if (all_users[i]["id"] == deluserid) {
|
||||
std::stringstream syslogstring;
|
||||
syslogstring << "user deleted [" << all_users[i]["username"] << "]";
|
||||
std::string syslogstring = "user deleted [" + std::string(all_users[i]["username"]) + "]";
|
||||
all_users.erase(i);
|
||||
found = true;
|
||||
syslog(LOG_INFO, syslogstring.str().c_str());
|
||||
syslog(LOG_INFO, syslogstring.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user