chenluhua1980
2026-01-26 d7c88780e1df54f34563d60bd7fa01011d2eef03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
 
#include <string>
#include <vector>
 
class CUserManager2
{
public:
    static CUserManager2& getInstance();
    CUserManager2(const CUserManager2&) = delete;
    CUserManager2& operator=(const CUserManager2&) = delete;
 
    struct RoleInfo
    {
        std::wstring name;
        int level = 0;
    };
 
    struct UserInfo
    {
        std::wstring userName;
        std::wstring displayName;
        std::wstring roleName;
        int roleLevel = 0;
        bool enabled = false;
    };
 
public:
    void init(const char* pszDir);
    bool login(const char* pszAccount, const char* pszPwd);
    bool isLoggedIn();
    std::string getCurrentUserName();
    bool IsAdminCurrent();
    std::vector<RoleInfo> getRoles();
    std::vector<UserInfo> getUsers();
    int addUser(const std::wstring& userName, const std::wstring& displayName,
        const std::wstring& password, const std::wstring& roleName, bool enabled);
    int updateUser(const std::wstring& userName, const std::wstring& displayName,
        const std::wstring& password, const std::wstring& roleName, bool enabled);
    int deleteUser(const std::wstring& userName);
    int setUserEnabled(const std::wstring& userName, bool enabled);
    int resetPassword(const std::wstring& userName, const std::wstring& password);
 
private:
    CUserManager2();
    ~CUserManager2();
};