2022-06-30 13:23:14 +02:00
|
|
|
#ifndef USER_CONTROLLER_H
|
|
|
|
#define USER_CONTROLLER_H
|
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
#include "core/reference.h"
|
|
|
|
#include "core/ustring.h"
|
2022-08-17 12:53:49 +02:00
|
|
|
#include "core/containers/vector.h"
|
2022-06-30 13:23:14 +02:00
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
#include "modules/web/http/web_node.h"
|
2022-06-30 13:23:14 +02:00
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
class WebServerRequest;
|
2022-06-30 13:23:14 +02:00
|
|
|
class FormValidator;
|
2022-07-22 12:09:00 +02:00
|
|
|
class User;
|
2022-07-07 21:53:28 +02:00
|
|
|
|
2022-06-30 13:23:14 +02:00
|
|
|
class UserController : public WebNode {
|
2022-07-22 12:09:00 +02:00
|
|
|
GDCLASS(UserController, WebNode);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
|
|
|
public:
|
2022-07-22 12:09:00 +02:00
|
|
|
void _handle_request_main(Ref<WebServerRequest> request);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
|
|
|
struct LoginRequestData {
|
|
|
|
String error_str;
|
|
|
|
String uname_val;
|
|
|
|
String pass_val;
|
|
|
|
};
|
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
virtual void handle_login_request_default(Ref<WebServerRequest> request);
|
|
|
|
virtual void render_login_request_default(Ref<WebServerRequest> request, LoginRequestData *data);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
|
|
|
struct RegisterRequestData {
|
|
|
|
String error_str;
|
|
|
|
String uname_val;
|
|
|
|
String email_val;
|
|
|
|
String pass_val;
|
|
|
|
String pass_check_val;
|
|
|
|
};
|
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
virtual void handle_register_request_default(Ref<WebServerRequest> request);
|
|
|
|
virtual void render_register_request_default(Ref<WebServerRequest> request, RegisterRequestData *data);
|
|
|
|
virtual void render_register_success(Ref<WebServerRequest> request);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
virtual void render_already_logged_in_error(Ref<WebServerRequest> request);
|
|
|
|
virtual void render_login_success(Ref<WebServerRequest> request);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
virtual void handle_request(Ref<User> &user, Ref<WebServerRequest> request);
|
|
|
|
virtual void handle_main_page_request(Ref<User> &user, Ref<WebServerRequest> request);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
|
|
|
struct SettingsRequestData {
|
|
|
|
String error_str;
|
|
|
|
|
|
|
|
String uname_val;
|
|
|
|
String email_val;
|
|
|
|
String pass_val;
|
|
|
|
String pass_check_val;
|
|
|
|
};
|
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
virtual void handle_settings_request(Ref<User> &user, Ref<WebServerRequest> request);
|
|
|
|
virtual void render_settings_request(Ref<User> &user, Ref<WebServerRequest> request, SettingsRequestData *data);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
2022-07-22 12:09:00 +02:00
|
|
|
virtual void handle_password_reset_request(Ref<User> &user, Ref<WebServerRequest> request);
|
|
|
|
virtual void handle_logout_request(Ref<User> &user, Ref<WebServerRequest> request);
|
|
|
|
virtual void handle_delete_request(Ref<User> &user, Ref<WebServerRequest> request);
|
2022-06-30 13:23:14 +02:00
|
|
|
|
|
|
|
UserController();
|
|
|
|
~UserController();
|
|
|
|
|
|
|
|
protected:
|
2022-07-22 12:09:00 +02:00
|
|
|
Ref<FormValidator> _login_validator;
|
|
|
|
Ref<FormValidator> _registration_validator;
|
|
|
|
Ref<FormValidator> _profile_validator;
|
2022-06-30 13:23:14 +02:00
|
|
|
};
|
|
|
|
|
2022-07-07 00:18:37 +02:00
|
|
|
#endif
|