2021-08-22 20:20:30 +02:00
|
|
|
#ifndef USER_CONTROLLER_H
|
|
|
|
#define USER_CONTROLLER_H
|
|
|
|
|
|
|
|
#include "core/object.h"
|
|
|
|
|
|
|
|
#include <string>
|
2021-08-22 22:03:35 +02:00
|
|
|
#include "user.h"
|
2021-08-22 20:20:30 +02:00
|
|
|
|
2021-08-22 22:03:35 +02:00
|
|
|
class Request;
|
|
|
|
class FormValidator;
|
2021-08-22 20:20:30 +02:00
|
|
|
|
|
|
|
class UserController : public Object {
|
|
|
|
public:
|
2021-08-22 22:03:35 +02:00
|
|
|
virtual void handle_request_default(Request *request);
|
|
|
|
|
2021-10-31 02:10:47 +02:00
|
|
|
struct LoginRequestData {
|
|
|
|
std::string error_str;
|
|
|
|
std::string uname_val;
|
|
|
|
std::string pass_val;
|
|
|
|
};
|
|
|
|
|
2021-08-22 22:03:35 +02:00
|
|
|
virtual void handle_login_request_default(Request *request);
|
2021-10-31 02:10:47 +02:00
|
|
|
virtual void render_login_request_default(Request *request, LoginRequestData *data);
|
|
|
|
|
|
|
|
struct RegisterRequestData {
|
|
|
|
std::string error_str;
|
|
|
|
std::string uname_val;
|
|
|
|
std::string email_val;
|
|
|
|
std::string pass_val;
|
|
|
|
std::string pass_check_val;
|
|
|
|
};
|
|
|
|
|
2021-08-22 22:03:35 +02:00
|
|
|
virtual void handle_register_request_default(Request *request);
|
2021-10-31 02:10:47 +02:00
|
|
|
virtual void render_register_request_default(Request *request, RegisterRequestData *data);
|
|
|
|
|
|
|
|
virtual void render_already_logged_in_error(Request *request);
|
2021-08-22 22:03:35 +02:00
|
|
|
|
|
|
|
virtual void handle_request(Ref<User> &user, Request *request);
|
|
|
|
virtual void handle_main_page_request(Ref<User> &user, Request *request);
|
2021-10-31 02:10:47 +02:00
|
|
|
|
|
|
|
struct SettingsRequestData {
|
|
|
|
std::string error_str;
|
|
|
|
|
|
|
|
std::string uname_val;
|
|
|
|
std::string email_val;
|
|
|
|
std::string pass_val;
|
|
|
|
std::string pass_check_val;
|
|
|
|
};
|
|
|
|
|
2021-08-22 22:03:35 +02:00
|
|
|
virtual void handle_settings_request(Ref<User> &user, Request *request);
|
2021-10-31 02:10:47 +02:00
|
|
|
virtual void render_settings_request(Ref<User> &user, Request *request, SettingsRequestData *data);
|
|
|
|
|
2021-08-22 22:03:35 +02:00
|
|
|
virtual void handle_password_reset_request(Ref<User> &user, Request *request);
|
|
|
|
virtual void handle_logout_request(Ref<User> &user, Request *request);
|
|
|
|
virtual void handle_delete_request(Ref<User> &user, Request *request);
|
|
|
|
|
2021-08-22 22:28:46 +02:00
|
|
|
virtual void create_validators();
|
|
|
|
|
|
|
|
static void user_session_setup_middleware(Object *instance, Request *request);
|
2021-08-22 22:03:35 +02:00
|
|
|
|
2021-08-22 20:20:30 +02:00
|
|
|
static UserController *get_singleton();
|
|
|
|
|
|
|
|
UserController();
|
|
|
|
~UserController();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static UserController *_self;
|
2021-08-22 22:03:35 +02:00
|
|
|
|
|
|
|
static FormValidator *_login_validator;
|
|
|
|
static FormValidator *_registration_validator;
|
|
|
|
static FormValidator *_profile_validator;
|
2021-08-22 20:20:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|