syslog added

This commit is contained in:
wt committed 2024-07-03 10:06:58 +07:00
1 parent e039ebc0d1
commit 0e07a65d8c
6 files changed
+21 -4

No files matched your search

+4 -2
View File
@@ -4,6 +4,7 @@
#include "auth/auth.hpp"
#include "users/users.hpp"
#include "colors.h"
#include <syslog.h>
#define CORS_ENABLE
@@ -28,7 +29,8 @@ int main() {
srv.set_mount_point("/auth/css", "../src/web/css");
std::cout << GREEN << "Starting" << RESET << " server on [ " << YELLOW
<< "localhost" << RESET << ":" << CYAN << "43243" << RESET << " ]" << std::endl;
srv.listen("localhost", 43243);
<< "0.0.0.0" << RESET << ":" << CYAN << "43243" << RESET << " ]" << std::endl;
syslog(LOG_INFO, "Authorization service started");
srv.listen("0.0.0.0", 43243);
return 0;
}
+4 -1
View File
@@ -3,6 +3,7 @@
#include "../includes.hpp"
#include "../auth/auth.hpp"
#include <jwt-cpp/jwt.h>
#include <syslog.h>
#define ALPHABET "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
@@ -96,6 +97,8 @@ void add_user(const httplib::Request &request, httplib::Response &response) {
std::ofstream usersfilew("users.json");
usersfilew << all_users.dump(4);
usersfilew.close();
std::stringstream syslogstring;
syslogstring << "user added [" << username << "]";
syslog(LOG_INFO, syslogstring.str().c_str());
response.set_content(R"({"status":"ok"})", JSON_TYPE);
}
+4
View File
@@ -3,6 +3,7 @@
#include "../includes.hpp"
#include "../auth/auth.hpp"
#include <jwt-cpp/jwt.h>
#include <syslog.h>
// functtion for change password for user
void change_password(const httplib::Request &request, httplib::Response &response) {
@@ -81,6 +82,9 @@ 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());
break;
}
}
+4
View File
@@ -3,6 +3,7 @@
#include "../includes.hpp"
#include "../auth/auth.hpp"
#include <jwt-cpp/jwt.h>
#include <syslog.h>
// function for change user data
void change_user(const httplib::Request &request, httplib::Response &response) {
@@ -73,6 +74,9 @@ 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());
break;
}
}
+4
View File
@@ -3,6 +3,7 @@
#include "../includes.hpp"
#include "../auth/auth.hpp"
#include <jwt-cpp/jwt.h>
#include <syslog.h>
// function for delete user
void delete_user(const httplib::Request &request, httplib::Response &response) {
@@ -62,6 +63,9 @@ void delete_user(const httplib::Request &request, httplib::Response &response) {
if (all_users[i]["id"] == deluserid) {
all_users.erase(i);
found = true;
std::stringstream syslogstring;
syslogstring << "user deleted [" << all_users[i]["username"] << "]";
syslog(LOG_INFO, syslogstring.str().c_str());
break;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
const host = 'http://localhost:43243'
const host = 'http://192.168.122.76:43243'
const prefix = 'api'
const routes = {