rcpp_framework/modules/users/user.h

85 lines
2.0 KiB
C
Raw Normal View History

#ifndef USER_H
#define USER_H
2021-08-21 16:38:06 +02:00
#include "core/resource.h"
2021-08-21 18:28:29 +02:00
#include <mutex>
#include <string>
#include <vector>
class Request;
2021-08-20 18:00:50 +02:00
class FormValidator;
2021-08-21 16:38:06 +02:00
class User : public Resource {
RCPP_OBJECT(User, Resource);
public:
std::string name_user_input;
std::string email_user_input;
int rank;
std::string pre_salt;
std::string post_salt;
std::string password_hash;
bool banned;
std::vector<std::string> sessions;
std::string password_reset_token;
bool locked;
virtual void save();
virtual void load();
virtual void load(const std::string &p_name);
virtual void load(const int p_id);
virtual void changed();
virtual void update();
2021-08-22 13:37:28 +02:00
void migrate();
static void db_load_all();
virtual bool check_password(const std::string &p_password);
virtual void create_password(const std::string &p_password);
virtual std::string hash_password(const std::string &p_password);
static void handle_request_default(Request *request);
static void handle_login_request_default(Request *request);
static void handle_register_request_default(Request *request);
virtual void handle_request(Request *request);
virtual void handle_main_page_request(Request *request);
virtual void handle_settings_request(Request *request);
virtual void handle_password_reset_request(Request *request);
virtual void handle_logout_request(Request *request);
virtual void handle_delete_request(Request *request);
2021-08-20 19:18:26 +02:00
static void create_validators();
2021-08-20 18:00:50 +02:00
void register_sessions();
void unregister_sessions();
2021-08-22 13:30:58 +02:00
void file_save();
void file_load();
void file_ensure_directory_exist();
std::string file_get_base_path();
static void file_load_all();
static std::string file_get_path();
static void file_set_path(const std::string &path);
std::string to_json(rapidjson::Document *into = nullptr);
void from_json(const std::string &data);
2021-08-21 18:28:29 +02:00
User();
~User();
2021-08-20 18:00:50 +02:00
2021-08-21 18:28:29 +02:00
protected:
2021-08-20 19:18:26 +02:00
static FormValidator *_login_validator;
static FormValidator *_registration_validator;
2021-08-20 20:32:40 +02:00
static FormValidator *_profile_validator;
2021-08-22 13:30:58 +02:00
std::string _file_path;
static std::string _path;
2021-08-22 13:37:28 +02:00
static std::string _table_name;
};
#endif