zoneminder/src/zm_user.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.2 KiB
C
Raw Normal View History

2013-03-17 07:45:21 +08:00
/*
* ZoneMinder User Class Interface, $Date$, $Revision$
* Copyright (C) 2001-2008 Philip Coombes
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2013-03-17 07:45:21 +08:00
*/
2013-03-17 07:45:21 +08:00
#ifndef ZM_USER_H
#define ZM_USER_H
#include "zm_db.h"
2019-08-28 22:34:30 +08:00
#include <string>
2017-11-19 05:00:10 +08:00
#include <vector>
2019-08-28 22:34:30 +08:00
2017-11-19 05:00:10 +08:00
class User {
2019-08-28 22:34:30 +08:00
public:
typedef enum { PERM_NONE = 1, PERM_VIEW, PERM_EDIT } Permission;
2013-03-17 07:45:21 +08:00
2019-08-28 22:34:30 +08:00
protected:
2018-02-13 18:26:08 +08:00
int id;
char username[32+1];
char password[64+1];
bool enabled;
Permission stream;
Permission events;
Permission control;
Permission monitors;
Permission system;
2017-11-19 05:00:10 +08:00
std::vector<int> monitor_ids;
2013-03-17 07:45:21 +08:00
2019-08-28 22:34:30 +08:00
public:
User();
2019-08-28 22:34:30 +08:00
explicit User(const MYSQL_ROW &dbrow);
~User();
2020-11-02 05:11:19 +08:00
User(const User &u) { Copy(u); }
2019-08-28 22:34:30 +08:00
void Copy(const User &u);
2018-04-12 23:29:35 +08:00
User& operator=(const User &u) {
2017-11-19 05:00:10 +08:00
Copy(u); return *this;
}
2013-03-17 07:45:21 +08:00
int Id() const { return id; }
2019-08-28 22:34:30 +08:00
const char *getUsername() const { return username; }
const char *getPassword() const { return password; }
bool isEnabled() const { return enabled; }
Permission getStream() const { return stream; }
Permission getEvents() const { return events; }
Permission getControl() const { return control; }
Permission getMonitors() const { return monitors; }
Permission getSystem() const { return system; }
bool canAccess(int monitor_id);
2013-03-17 07:45:21 +08:00
};
2019-08-28 22:34:30 +08:00
User *zmLoadUser(const char *username, const char *password=0);
User *zmLoadAuthUser(const char *auth, bool use_remote_addr);
User *zmLoadTokenUser(std::string jwt, bool use_remote_addr);
bool checkUser(const char *username);
bool checkPass(const char *password);
2013-03-17 07:45:21 +08:00
#endif // ZM_USER_H