From 1a19a11081e56aff745ca0ba625187fabc54fb94 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Tue, 8 Sep 2009 19:50:00 +0200 Subject: new files for user management --- users.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 users.h (limited to 'users.h') diff --git a/users.h b/users.h new file mode 100644 index 0000000..b845352 --- /dev/null +++ b/users.h @@ -0,0 +1,69 @@ +#ifndef VDR_LIVE_USERS_H +#define VDR_LIVE_USERS_H + +#include +#include +#include +#include +#include + +namespace vdrlive { + +enum eUserRights +{ + UR_EDITSETUP=1, + UR_EDITTIMERS, + UR_DELTIMERS, + UR_DELRECS, + UR_USEREMOTE, + UR_STARTREPLAY, + UR_SWITCHCHNL, + UR_EDITSTIMERS, + UR_DELSTIMERS +}; + +// --- 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 { + 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 -- cgit v1.2.3