Feature: Implement user management feature with role support
This commit is contained in:
@@ -78,6 +78,11 @@ public:
|
||||
// Set admin password (use master password)
|
||||
void SetAdminPassword(const std::string& password);
|
||||
|
||||
// User management
|
||||
bool CreateUser(const std::string& username, const std::string& password, const std::string& role);
|
||||
bool DeleteUser(const std::string& username);
|
||||
std::vector<std::pair<std::string, std::string>> ListUsers(); // Returns [(username, role), ...]
|
||||
|
||||
// Device management (called from main app)
|
||||
void MarkDeviceOnline(uint64_t device_id);
|
||||
void MarkDeviceOffline(uint64_t device_id);
|
||||
@@ -111,6 +116,7 @@ private:
|
||||
|
||||
// Signaling handlers
|
||||
void HandleLogin(void* ws_ptr, const std::string& msg, const std::string& client_ip);
|
||||
void HandleGetSalt(void* ws_ptr, const std::string& msg);
|
||||
void HandleGetDevices(void* ws_ptr, const std::string& token);
|
||||
void HandleConnect(void* ws_ptr, const std::string& token, uint64_t device_id);
|
||||
void HandleDisconnect(void* ws_ptr, const std::string& token, uint64_t requested_device_id = 0);
|
||||
@@ -141,6 +147,14 @@ private:
|
||||
bool VerifyPassword(const std::string& input, const WebUser& user);
|
||||
std::string ComputeHash(const std::string& input);
|
||||
|
||||
// User management helpers
|
||||
std::string GetUsersFilePath();
|
||||
void LoadUsers();
|
||||
void SaveUsers();
|
||||
void HandleCreateUser(void* ws_ptr, const std::string& msg);
|
||||
void HandleDeleteUser(void* ws_ptr, const std::string& msg);
|
||||
void HandleListUsers(void* ws_ptr, const std::string& token);
|
||||
|
||||
// Send to WebSocket
|
||||
void SendText(void* ws_ptr, const std::string& text);
|
||||
void SendBinary(void* ws_ptr, const uint8_t* data, size_t len);
|
||||
@@ -181,6 +195,7 @@ private:
|
||||
|
||||
// User accounts (loaded from config)
|
||||
std::vector<WebUser> m_Users;
|
||||
std::mutex m_UsersMutex;
|
||||
|
||||
// Token secret key (generated on startup)
|
||||
std::string m_SecretKey;
|
||||
@@ -190,6 +205,7 @@ private:
|
||||
int m_nTokenExpireSeconds;
|
||||
bool m_bHideWebSessions; // Whether to hide web-triggered dialogs (default: true)
|
||||
std::string m_PayloadsDir; // Directory for file downloads (Payloads/)
|
||||
std::string m_ConfigDir; // Directory for config files (users.json, etc.)
|
||||
|
||||
// Web-triggered sessions (should be hidden)
|
||||
std::set<uint64_t> m_WebTriggeredDevices;
|
||||
|
||||
Reference in New Issue
Block a user