Some todos / notes.

This commit is contained in:
Relintai 2022-07-07 00:18:37 +02:00
parent eb251fef19
commit d469473ec8
2 changed files with 13 additions and 14 deletions

View File

@ -56,7 +56,6 @@ void UserController::handle_login_request_default(Request *request) {
LoginRequestData data; LoginRequestData data;
if (request->get_method() == HTTP_METHOD_POST) { if (request->get_method() == HTTP_METHOD_POST) {
// this is probbaly not needed // this is probbaly not needed
// it's ok for now as I need to test the validators more // it's ok for now as I need to test the validators more
Vector<String> errors; Vector<String> errors;
@ -115,7 +114,6 @@ void UserController::render_login_request_default(Request *request, LoginRequest
b.div()->cls("login"); b.div()->cls("login");
{ {
// todo href path helper // todo href path helper
b.form()->method("POST")->href("/user/login"); b.form()->method("POST")->href("/user/login");
{ {
@ -149,7 +147,6 @@ void UserController::handle_register_request_default(Request *request) {
RegisterRequestData data; RegisterRequestData data;
if (request->get_method() == HTTP_METHOD_POST) { if (request->get_method() == HTTP_METHOD_POST) {
Vector<String> errors; Vector<String> errors;
_registration_validator->validate(request, &errors); _registration_validator->validate(request, &errors);
@ -315,11 +312,9 @@ void UserController::handle_main_page_request(Ref<User> &user, Request *request)
} }
void UserController::handle_settings_request(Ref<User> &user, Request *request) { void UserController::handle_settings_request(Ref<User> &user, Request *request) {
SettingsRequestData data; SettingsRequestData data;
if (request->get_method() == HTTP_METHOD_POST) { if (request->get_method() == HTTP_METHOD_POST) {
data.uname_val = request->get_parameter("username"); data.uname_val = request->get_parameter("username");
data.email_val = request->get_parameter("email"); data.email_val = request->get_parameter("email");
data.pass_val = request->get_parameter("password"); data.pass_val = request->get_parameter("password");
@ -775,7 +770,6 @@ UserController *UserController::get_singleton() {
UserController::UserController() : UserController::UserController() :
WebNode() { WebNode() {
if (_self) { if (_self) {
printf("UserController::UserController(): Error! self is not null!/n"); printf("UserController::UserController(): Error! self is not null!/n");
} }
@ -800,14 +794,12 @@ FormValidator *UserController::_profile_validator = nullptr;
String UserController::_path = "./"; String UserController::_path = "./";
String UserController::_table_name = "users"; String UserController::_table_name = "users";
// returnring true means handled, false means continue // returnring true means handled, false means continue
bool UserSessionSetupMiddleware::on_before_handle_request_main(Request *request) { bool UserSessionSetupMiddleware::on_before_handle_request_main(Request *request) {
if (request->session.is_valid()) { if (request->session.is_valid()) {
int user_id = request->session->get_int("user_id"); int user_id = request->session->get_int("user_id");
if (user_id != 0) { if (user_id != 0) {
Ref<User> u = UserController::get_singleton()->db_get_user(user_id); Ref<User> u = UserController::get_singleton()->db_get_user(user_id);
if (u.is_valid()) { if (u.is_valid()) {

View File

@ -12,6 +12,14 @@
class Request; class Request;
class FormValidator; class FormValidator;
//TODO
// Break this up into multiple small webnodes (per page)
// that would make this a lot more customizable
// Only User management, save, load etc should be kept here
// and this node should be expected to be autoloaded.
// It should keep get_singleton() and c++ stuff that deal with users should expect it's presence
// they should use err macros to not crash the app though
class UserController : public WebNode { class UserController : public WebNode {
RCPP_OBJECT(UserController, WebNode); RCPP_OBJECT(UserController, WebNode);
@ -114,5 +122,4 @@ public:
~UserSessionSetupMiddleware(); ~UserSessionSetupMiddleware();
}; };
#endif #endif