瀏覽代碼

fix: pass actor_id in HTTP handlers for create/update operations

Set actor_id from authenticated user when creating or updating
users, workspaces, and groups to properly track who made changes.
Fszontagh 6 月之前
父節點
當前提交
6f720ecc8b
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      webserver/src/http_server.cpp

+ 6 - 0
webserver/src/http_server.cpp

@@ -1178,6 +1178,7 @@ void HttpServer::HandleCreateUser(const httplib::Request& req, httplib::Response
         auto body = nlohmann::json::parse(req.body);
 
         CreateUserRequest create_req;
+        create_req.actor_id = auth_user->user_id;
         if (body.contains("email")) {
             create_req.email = body["email"].get<std::string>();
         }
@@ -1391,6 +1392,7 @@ void HttpServer::HandleUpdateUser(const httplib::Request& req, httplib::Response
         auto body = nlohmann::json::parse(req.body);
 
         UpdateUserRequest update_req;
+        update_req.actor_id = auth_user->user_id;
         if (body.contains("email")) {
             update_req.email = body["email"].get<std::string>();
         }
@@ -1536,6 +1538,7 @@ void HttpServer::HandleCreateWorkspace(const httplib::Request& req, httplib::Res
         auto body = nlohmann::json::parse(req.body);
 
         CreateWorkspaceRequest create_req;
+        create_req.actor_id = auth_user->user_id;
         if (body.contains("name")) {
             create_req.name = body["name"].get<std::string>();
         }
@@ -1750,6 +1753,7 @@ void HttpServer::HandleUpdateWorkspace(const httplib::Request& req, httplib::Res
         auto body = nlohmann::json::parse(req.body);
 
         UpdateWorkspaceRequest update_req;
+        update_req.actor_id = auth_user->user_id;
         if (body.contains("name")) {
             update_req.name = body["name"].get<std::string>();
         }
@@ -1903,6 +1907,7 @@ void HttpServer::HandleCreateGroup(const httplib::Request& req, httplib::Respons
 
         CreateGroupRequest create_req;
         create_req.workspace_id = workspace_id;
+        create_req.actor_id = auth_user->user_id;
         if (body.contains("name")) {
             create_req.name = body["name"].get<std::string>();
         }
@@ -2184,6 +2189,7 @@ void HttpServer::HandleUpdateGroup(const httplib::Request& req, httplib::Respons
         auto body = nlohmann::json::parse(req.body);
 
         UpdateGroupRequest update_req;
+        update_req.actor_id = auth_user->user_id;
         if (body.contains("name")) {
             update_req.name = body["name"].get<std::string>();
         }