-
Notifications
You must be signed in to change notification settings - Fork 13
/
users.h
74 lines (63 loc) · 2.04 KB
/
users.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef VDR_LIVE_USERS_H
#define VDR_LIVE_USERS_H
// STL headers need to be before VDR tools.h (included by <vdr/channels.h>)
#include <string>
#if TNTVERSION >= 30000
#include <cxxtools/log.h> // must be loaded before any VDR include because of duplicate macros (LOG_ERROR, LOG_DEBUG, LOG_INFO)
#endif
#include <vdr/tools.h>
#include <vdr/config.h>
namespace vdrlive {
enum eUserRights
{
UR_EDITSETUP=1,
UR_EDITTIMERS,
UR_DELTIMERS,
UR_DELRECS,
UR_USEREMOTE,
UR_STARTREPLAY,
UR_SWITCHCHNL,
UR_EDITSTIMERS,
UR_DELSTIMERS,
UR_EDITRECS
};
// --- cUser --------------------------------------------------------
class cUser : public cListObject {
int m_ID;
std::string m_Name;
std::string m_PasswordMD5;
int m_Userrights;
public:
cUser() : m_ID(-1), m_Userrights(0) {}
cUser(int ID, const std::string& Name, const std::string& Password);
int Id() const { return m_ID; }
std::string Name() const { return m_Name; }
std::string PasswordMD5() const { return m_PasswordMD5; }
int Userrights() const { return m_Userrights; }
int GetPasswordLength() const;
std::string const GetMD5HashPassword() const;
void SetId(int Id) { m_ID = Id; }
void SetName(const std::string& Name) { m_Name = Name; }
void SetPassword(const std::string& Password);
void SetUserrights(int Userrights) { m_Userrights = Userrights; }
bool HasRightTo(eUserRights right);
static bool CurrentUserHasRightTo(eUserRights right);
void SetRight(eUserRights right);
bool Parse(const char *s);
const char *ToText(void);
bool Save(FILE *f);
};
// --- cUsers --------------------------------------------------------
class cUsers : public cConfig<cUser> {
public:
bool ValidUserLogin(const std::string& login, const std::string& password);
bool ValidLogin(const std::string& login, const std::string& password);
bool Delete(const std::string& Name);
static cUser* GetByUserId(const std::string& Id);
static cUser* GetByUserName(const std::string& Name);
int GetNewId();
static std::string logged_in_user;
};
extern cUsers Users;
}
#endif