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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user