Work on handle_login_request_default.

This commit is contained in:
Relintai 2021-08-05 18:26:11 +02:00
parent 45af98ab18
commit a4c28867f2

View File

@ -1,9 +1,11 @@
#include "user.h"
#include "core/html/html_builder.h"
#include "core/http/http_session.h"
#include "core/http/request.h"
#include "core/http/session_manager.h"
#include "core/html/html_builder.h"
#include "core/utils.h"
#include "user_manager.h"
void User::save() {
}
@ -102,14 +104,28 @@ void User::handle_login_request_default(Request *request) {
std::string pass_val = "";
if (request->get_method() == HTTP_METHOD_POST) {
request->body += "handle_login_request_default POST<br>";
uname_val = request->get_parameter("username");
pass_val = request->get_parameter("password");
User *user = UserManager::get_singleton()->get_user(uname_val);
if (user) {
//todo
} else {
error_str = "Invalid username or password!";
}
}
HTMLBuilder b;
if (error_str.size() != 0) {
b.div()->cls("error");
b.w(error_str);
b.cdiv();
}
b.div()->cls("login");
//todo href path helper
@ -130,7 +146,6 @@ void User::handle_login_request_default(Request *request) {
b.cdiv();
request->body += b.result;
request->compile_and_send_body();