Removed the user controller.

This commit is contained in:
Relintai 2021-11-19 22:23:41 +01:00
parent 0e5b1c3cd7
commit 6fe5ea3fdc
2 changed files with 0 additions and 216 deletions

View File

@ -1,191 +0,0 @@
#include "ccms_user_controller.h"
#include "core/html/form_validator.h"
#include "core/html/html_builder.h"
#include "core/http/cookie.h"
#include "core/http/http_session.h"
#include "core/http/request.h"
#include "core/http/session_manager.h"
#include "modules/users/user_model.h"
void CCMSUserController::render_login_request_default(Request *request, LoginRequestData *data) {
HTMLBuilder b;
b.w("Login");
b.br();
{
if (data->error_str.size() != 0) {
b.div()->cls("error");
b.w(data->error_str);
b.cdiv();
}
}
b.div()->cls("login");
{
//todo href path helper
b.form()->method("POST")->href("/user/login");
{
b.w("Username");
b.br();
b.input()->type("text")->name("username")->value(data->uname_val);
b.cinput();
b.br();
b.w("Password");
b.br();
b.input()->type("password")->name("password");
b.cinput();
b.br();
b.input()->type("submit")->value("Send");
b.cinput();
}
b.cform();
b.a()->href("/user/register");
b.w("Register");
b.ca();
}
b.cdiv();
request->body += b.result;
request->compile_and_send_body();
}
void CCMSUserController::render_register_request_default(Request *request, RegisterRequestData *data) {
HTMLBuilder b;
b.w("Registration");
b.br();
{
if (data->error_str.size() != 0) {
b.div()->cls("error");
b.w(data->error_str);
b.cdiv();
}
}
b.div()->cls("register");
{
//todo href path helper
b.form()->method("POST")->href("/user/register");
{
b.w("Username");
b.br();
b.input()->type("text")->name("username")->value(data->uname_val);
b.cinput();
b.br();
b.w("Email");
b.br();
b.input()->type("email")->name("email")->value(data->email_val);
b.cinput();
b.br();
b.w("Password");
b.br();
b.input()->type("password")->name("password");
b.cinput();
b.br();
b.w("Password again");
b.br();
b.input()->type("password")->name("password_check");
b.cinput();
b.br();
b.input()->type("submit")->value("Register");
b.cinput();
}
b.cform();
}
b.cdiv();
request->body += b.result;
request->compile_and_send_body();
}
void CCMSUserController::render_login_success(Request *request) {
request->body = "Login Success!<br>";
request->send_redirect("/");
}
void CCMSUserController::render_already_logged_in_error(Request *request) {
request->body += "You are already logged in.";
request->compile_and_send_body();
}
void CCMSUserController::render_settings_request(Ref<User> &user, Request *request, SettingsRequestData *data) {
HTMLBuilder b;
b.w("Settings");
b.br();
{
if (data->error_str.size() != 0) {
b.div()->cls("error");
b.w(data->error_str);
b.cdiv();
}
}
b.div()->cls("settings");
{
//todo href path helper
b.form()->method("POST")->href("/user/settings");
{
b.w("Username");
b.br();
b.input()->type("text")->name("username")->placeholder(user->name_user_input)->value(data->uname_val);
b.cinput();
b.br();
b.w("Email");
b.br();
b.input()->type("email")->name("email")->placeholder(user->email_user_input)->value(data->email_val);
b.cinput();
b.br();
b.w("Password");
b.br();
b.input()->type("password")->placeholder("*******")->name("password");
b.cinput();
b.br();
b.w("Password again");
b.br();
b.input()->type("password")->placeholder("*******")->name("password_check");
b.cinput();
b.br();
b.input()->type("submit")->value("Save");
b.cinput();
}
b.cform();
}
b.cdiv();
request->body += b.result;
request->compile_and_send_body();
}
CCMSUserController::CCMSUserController() :
RBACUserController() {
}
CCMSUserController::~CCMSUserController() {
}

View File

@ -1,25 +0,0 @@
#ifndef CCMS_USER_CONTROLLER_H
#define CCMS_USER_CONTROLLER_H
#include "modules/rbac_users/rbac_user_controller.h"
#include <string>
#include "modules/users/user.h"
class Request;
class FormValidator;
class CCMSUserController : public RBACUserController {
RCPP_OBJECT(CCMSUserController, RBACUserController);
public:
void render_login_request_default(Request *request, LoginRequestData *data);
void render_register_request_default(Request *request, RegisterRequestData *data);
void render_login_success(Request *request);
void render_already_logged_in_error(Request *request);
void render_settings_request(Ref<User> &user, Request *request, SettingsRequestData *data);
CCMSUserController();
~CCMSUserController();
};
#endif