diff --git a/modules/users/user_controller.cpp b/modules/users/user_controller.cpp index 294296b..c758855 100644 --- a/modules/users/user_controller.cpp +++ b/modules/users/user_controller.cpp @@ -71,11 +71,7 @@ void UserController::handle_login_request_default(Request *request) { request->add_cookie(c); - //todo implement redirect! - - request->body += "Login Success!
"; - - request->compile_and_send_body(); + render_login_success(request); return; } @@ -177,21 +173,7 @@ void UserController::handle_register_request_default(Request *request) { UserModel::get_singleton()->create_password(user, data.pass_val); UserModel::get_singleton()->save_user(user); - HTMLBuilder b; - - b.div()->cls("success"); - { - b.w("Registration successful! You can now log in!"); - b.br(); - b.a()->href("/user/login"); - b.w(">> Login <<"); - b.ca(); - } - b.cdiv(); - - request->body += b.result; - - request->compile_and_send_body(); + render_register_success(request); return; } } @@ -199,6 +181,24 @@ void UserController::handle_register_request_default(Request *request) { render_register_request_default(request, &data); } +void UserController::render_register_success(Request *request) { + HTMLBuilder b; + + b.div()->cls("success"); + { + b.w("Registration successful! You can now log in!"); + b.br(); + b.a()->href("/user/login"); + b.w(">> Login <<"); + b.ca(); + } + b.cdiv(); + + request->body += b.result; + + request->compile_and_send_body(); +} + void UserController::render_register_request_default(Request *request, RegisterRequestData *data) { HTMLBuilder b; @@ -262,6 +262,13 @@ void UserController::render_already_logged_in_error(Request *request) { request->compile_and_send_body(); } +void UserController::render_login_success(Request *request) { + request->body = "Login Success!
"; + + //request->compile_and_send_body(); + request->send_redirect("/user/settings"); +} + void UserController::handle_request(Ref &user, Request *request) { const std::string &segment = request->get_current_path_segment(); diff --git a/modules/users/user_controller.h b/modules/users/user_controller.h index e64b611..05f634f 100644 --- a/modules/users/user_controller.h +++ b/modules/users/user_controller.h @@ -34,8 +34,10 @@ public: virtual void handle_register_request_default(Request *request); virtual void render_register_request_default(Request *request, RegisterRequestData *data); + virtual void render_register_success(Request *request); virtual void render_already_logged_in_error(Request *request); + virtual void render_login_success(Request *request); virtual void handle_request(Ref &user, Request *request); virtual void handle_main_page_request(Ref &user, Request *request);