2021-08-22 20:23:06 +02:00
|
|
|
#ifndef USER_MODEL_H
|
|
|
|
#define USER_MODEL_H
|
|
|
|
|
|
|
|
#include "core/object.h"
|
|
|
|
|
2021-08-22 21:46:24 +02:00
|
|
|
#include "user.h"
|
2021-08-22 20:23:06 +02:00
|
|
|
#include <string>
|
2021-08-22 21:46:24 +02:00
|
|
|
#include <vector>
|
2021-08-22 20:23:06 +02:00
|
|
|
|
|
|
|
class UserModel : public Object {
|
|
|
|
public:
|
2021-08-22 21:46:24 +02:00
|
|
|
Ref<User> get_user(const int id);
|
|
|
|
Ref<User> get_user(const std::string &user_name_input);
|
|
|
|
void save_user(Ref<User> &user);
|
|
|
|
|
|
|
|
std::vector<Ref<User> > get_all();
|
|
|
|
|
|
|
|
bool is_username_taken(const std::string &user_name_input);
|
|
|
|
bool is_email_taken(const std::string &email_input);
|
|
|
|
|
|
|
|
virtual bool check_password(const Ref<User> &user, const std::string &p_password);
|
|
|
|
virtual void create_password(Ref<User> &user, const std::string &p_password);
|
|
|
|
virtual std::string hash_password(const Ref<User> &user, const std::string &p_password);
|
|
|
|
|
|
|
|
virtual void create_table();
|
|
|
|
virtual void drop_table();
|
|
|
|
virtual void migrate();
|
2021-08-22 20:41:59 +02:00
|
|
|
|
2021-08-22 20:23:06 +02:00
|
|
|
static UserModel *get_singleton();
|
|
|
|
|
|
|
|
UserModel();
|
|
|
|
~UserModel();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static UserModel *_self;
|
2021-08-22 21:46:24 +02:00
|
|
|
|
|
|
|
std::string _file_path;
|
|
|
|
|
|
|
|
static std::string _path;
|
|
|
|
static std::string _table_name;
|
2021-08-22 20:23:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|