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

This commit is contained in:
wt
2025-02-13 19:35:42 +07:00
parent 77a483a38a
commit e5abe4bb02
23 changed files with 22332 additions and 21478 deletions
+10 -8
View File
@@ -6,7 +6,8 @@
#include <syslog.h>
// functtion for change password for user
void change_password(const httplib::Request &request, httplib::Response &response) {
void change_password(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()) {
@@ -36,7 +37,7 @@ void change_password(const httplib::Request &request, httplib::Response &respons
}
if (json_body["new_password"] == nullptr) {
response.set_content(CHANGE_PASSWORD_REQUIRED_STRING,
JSON_TYPE);
JSON_TYPE);
syslog(LOG_ERR, "no new password in change password request");
return;
}
@@ -66,7 +67,7 @@ void change_password(const httplib::Request &request, httplib::Response &respons
if (json_body["userid"] != nullptr) {
changepassuserid = 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;
}
@@ -85,23 +86,24 @@ void change_password(const httplib::Request &request, httplib::Response &respons
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"] == changepassuserid)) {
all_user["password"] = new_password;
found = true;
std::stringstream syslogstring;
syslogstring << "password changed for user [" << all_user["username"] << "]";
syslogstring << "password 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"] == changepassuserid) && (all_user["password"] == old_password)) {
all_user["password"] = new_password;
found = true;
std::stringstream syslogstring;
syslogstring << "password changed for user [" << all_user["username"] << "]";
syslogstring << "password changed for user [" << all_user["username"] << "]";
syslog(LOG_INFO, syslogstring.str().c_str());
break;
}