2021-07-07 12:20:05 +02:00
|
|
|
#ifndef USER_H
|
|
|
|
#define USER_H
|
|
|
|
|
2021-11-01 19:53:35 +01:00
|
|
|
#include "core/string.h"
|
|
|
|
|
2021-08-21 16:38:06 +02:00
|
|
|
#include "core/resource.h"
|
2021-07-07 12:20:05 +02:00
|
|
|
|
2021-08-21 18:28:29 +02:00
|
|
|
#include <mutex>
|
2021-07-07 12:20:05 +02:00
|
|
|
|
2021-08-05 01:19:54 +02:00
|
|
|
class Request;
|
2021-08-20 18:00:50 +02:00
|
|
|
class FormValidator;
|
2021-08-05 01:19:54 +02:00
|
|
|
|
2021-08-21 16:38:06 +02:00
|
|
|
class User : public Resource {
|
|
|
|
RCPP_OBJECT(User, Resource);
|
2021-08-05 01:19:54 +02:00
|
|
|
|
2021-07-07 12:20:05 +02:00
|
|
|
public:
|
2022-01-06 11:12:43 +01:00
|
|
|
enum Permissions {
|
|
|
|
PERMISSION_CREATE = 1 << 0,
|
|
|
|
PERMISSION_READ = 1 << 1,
|
|
|
|
PERMISSION_UPDATE = 1 << 2,
|
|
|
|
PERMISSION_DELETE = 1 << 3,
|
|
|
|
|
|
|
|
PERMISSION_ALL = PERMISSION_CREATE | PERMISSION_READ | PERMISSION_UPDATE | PERMISSION_DELETE,
|
|
|
|
PERMISSION_NONE = 0
|
|
|
|
};
|
|
|
|
|
2021-11-01 19:53:35 +01:00
|
|
|
String name_user_input;
|
|
|
|
String email_user_input;
|
2021-08-22 13:46:39 +02:00
|
|
|
int rank;
|
2021-11-01 19:53:35 +01:00
|
|
|
String pre_salt;
|
|
|
|
String post_salt;
|
|
|
|
String password_hash;
|
2021-08-22 13:46:39 +02:00
|
|
|
bool banned;
|
2021-11-01 19:53:35 +01:00
|
|
|
String password_reset_token;
|
2021-08-22 13:46:39 +02:00
|
|
|
bool locked;
|
2021-08-03 21:10:24 +02:00
|
|
|
|
2021-11-01 19:53:35 +01:00
|
|
|
String to_json(rapidjson::Document *into = nullptr);
|
|
|
|
void from_json(const String &data);
|
2021-08-21 18:28:29 +02:00
|
|
|
|
2022-01-06 11:12:43 +01:00
|
|
|
virtual int get_permissions(Request *request);
|
|
|
|
virtual bool has_permission(Request *request, const int permission);
|
|
|
|
virtual int get_additional_permissions(Request *request);
|
|
|
|
virtual bool has_additional_permission(Request *request, const int permission);
|
|
|
|
|
2021-07-07 12:20:05 +02:00
|
|
|
User();
|
|
|
|
~User();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|