From 1a456c5d736a06d2ee21becca2aa963961118b1e Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Wed, 16 Aug 2023 02:23:44 -0400 Subject: [PATCH] basic login post --- crow_test/index.html | 13 ------- crow_test/posta.html | 0 crow_test/webcontent/login.html | 27 ++++++++++++++ include/crowsite/site/auth.h | 14 +++++++ src/crowsite/site/auth.cpp | 8 ++++ src/main.cpp | 66 +++++---------------------------- 6 files changed, 59 insertions(+), 69 deletions(-) delete mode 100644 crow_test/index.html delete mode 100644 crow_test/posta.html create mode 100644 crow_test/webcontent/login.html create mode 100644 include/crowsite/site/auth.h create mode 100644 src/crowsite/site/auth.cpp diff --git a/crow_test/index.html b/crow_test/index.html deleted file mode 100644 index f2d4439..0000000 --- a/crow_test/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - -

Hello {{person}}!

-
- -

- -

- -
- - diff --git a/crow_test/posta.html b/crow_test/posta.html deleted file mode 100644 index e69de29..0000000 diff --git a/crow_test/webcontent/login.html b/crow_test/webcontent/login.html new file mode 100644 index 0000000..1154fbf --- /dev/null +++ b/crow_test/webcontent/login.html @@ -0,0 +1,27 @@ + + + + + + {{$SITE_TITLE}} + + +
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + diff --git a/include/crowsite/site/auth.h b/include/crowsite/site/auth.h new file mode 100644 index 0000000..a2677ac --- /dev/null +++ b/include/crowsite/site/auth.h @@ -0,0 +1,14 @@ +// +// Created by brett on 16/08/23. +// + +#ifndef CROWSITE_AUTH_H +#define CROWSITE_AUTH_H + +namespace cs { + + + +} + +#endif //CROWSITE_AUTH_H diff --git a/src/crowsite/site/auth.cpp b/src/crowsite/site/auth.cpp new file mode 100644 index 0000000..b547432 --- /dev/null +++ b/src/crowsite/site/auth.cpp @@ -0,0 +1,8 @@ +// +// Created by brett on 16/08/23. +// +#include + +namespace cs { + +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 9176cbd..061fa84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,60 +56,6 @@ int main(int argc, const char** argv) cs::jellyfin::authenticateUser(blt::arg_parse::get(args["user"]), blt::arg_parse::get(args["pass"])); - // blt::string::StringBuffer buffer; -// std::stringstream stream; -// std::string normalString; -// std::string normalStringReserved; -// -// const int bufferSize = 12030; -// const int runCount = 1024; -// const char chars[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; -// -// for (int _ = 0; _ < runCount; _++) { -// BLT_START_INTERVAL("Writing", "StringBuffer"); -// for (int i = 0; i < bufferSize; i++) -// buffer << chars[i % 26]; -// BLT_END_INTERVAL("Writing", "StringBuffer"); -// -// BLT_START_INTERVAL("Trim", "StringBuffer"); -// auto bs = buffer.str(); -// BLT_END_INTERVAL("Trim", "StringBuffer"); -// -// BLT_START_INTERVAL("Writing", "NormalString"); -// for (int i = 0; i < bufferSize; i++) -// normalString += chars[i % 26]; -// BLT_END_INTERVAL("Writing", "NormalString"); -// -// BLT_START_INTERVAL("Writing", "NormalStringReserved"); -// for (int i = 0; i < bufferSize; i++) -// normalStringReserved += chars[i % 26]; -// BLT_END_INTERVAL("Writing", "NormalStringReserved"); -// -// BLT_START_INTERVAL("Writing", "StringStream"); -// for (int i = 0; i < bufferSize; i++) -// stream << chars[i % 26]; -// BLT_END_INTERVAL("Writing", "StringStream"); -// -// BLT_START_INTERVAL("Trim", "StringStream"); -// auto ss = stream.str(); -// BLT_END_INTERVAL("Trim", "StringStream"); -// -// for (size_t i = 0; i < bs.size(); i++){ -// if (bs[i] != ss[i]){ -// BLT_ERROR("String length %d vs %d", bs.size(), ss.size()); -// BLT_ERROR("String has an error at pos %d. expected %c got %c", i, ss[i], bs[i]); -// return 1; -// } -// } -// } -// -// BLT_PRINT_PROFILE("Writing", blt::logging::BLT_NONE, true); -// BLT_PRINT_PROFILE("Trim", blt::logging::BLT_NONE, true); -// -// return 0; - - - BLT_INFO("Starting site %s.", SITE_NAME); crow::mustache::set_global_base(SITE_FILES_PATH); static BLT_CrowLogger bltCrowLogger{}; @@ -145,9 +91,17 @@ int main(int argc, const char** argv) ); CROW_ROUTE(app, "/")( - [&](const std::string& name) -> crow::response { + [&](const crow::request& req, const std::string& name) -> crow::response { //auto page = crow::mustache::load("index.html"); // //return "Hello There

Suck it " + name + "

"; +// BLT_TRACE(req.body); +// for (const auto& h : req.headers) +// BLT_TRACE("Header: %s = %s", h.first.c_str(), h.second.c_str()); +// BLT_TRACE(req.raw_url); +// BLT_TRACE(req.url); +// BLT_TRACE(req.remote_ip_address); +// for (const auto& v : req.url_params.keys()) +// BLT_TRACE("URL: %s = %s", v.c_str(), req.url_params.get(v)); if (name.ends_with(".html")) return {engine.fetch(name)}; @@ -160,7 +114,7 @@ int main(int argc, const char** argv) } ); - CROW_ROUTE(app, "/req/posta.html").methods(crow::HTTPMethod::POST)( + CROW_ROUTE(app, "/res/login").methods(crow::HTTPMethod::POST)( [](const crow::request& req) { cs::parser::Post pp(req.body);