diff --git a/source/json_settings.h b/source/json_settings.h index 48fd866..9932c4e 100644 --- a/source/json_settings.h +++ b/source/json_settings.h @@ -3,7 +3,6 @@ #include "json.hpp" #include - namespace AppSettings { static constexpr char settingsFile[] = "assets/settings.json"; diff --git a/source/login/login.cpp b/source/login/login.cpp index 16d6990..cf9baa9 100644 --- a/source/login/login.cpp +++ b/source/login/login.cpp @@ -1,15 +1,13 @@ #include "login.hpp" -#include "crow/http_response.h" #include "databasepool.h" #include "SessionHandler.hpp" -#include namespace login { SessionHandler sessionHandler; -std::string getSessionId(const crow::request& req) { +static std::string getSessionId(const crow::request& req) { auto cookie_header = req.get_header_value("Cookie"); std::string prefix = "session_id="; auto pos = cookie_header.find(prefix); @@ -24,6 +22,15 @@ static crow::response redirectToLogin(){ return res; } +static std::optional loginUser(const std::string& username, const std::string& password) +{ + auto user = getVerifiedUser(username, password); + if (user) { + return sessionHandler.createSession(user->id); + } + return {}; +} + std::optional isLoggedIn(const crow::request& req) { std::string sessionId = getSessionId(req); if (sessionId.empty()) @@ -36,15 +43,6 @@ std::optional isLoggedIn(const crow::request& req) { return {}; } -std::optional loginUser(const std::string& username, const std::string& password) -{ - auto user = getVerifiedUser(username, password); - if (user) { - return sessionHandler.createSession(user->id); - } - return {}; -} - void initLogin(crow::App& app){ createUser("lukas", "Trollar4928"); diff --git a/source/login/login.hpp b/source/login/login.hpp index a7ea584..c4e5e7a 100644 --- a/source/login/login.hpp +++ b/source/login/login.hpp @@ -3,7 +3,8 @@ #pragma once -#include +#include +#include #include "crow/middlewares/cors.h" namespace login { diff --git a/source/login/loginDb.hpp b/source/login/loginDb.hpp index 9b71980..f8f83af 100644 --- a/source/login/loginDb.hpp +++ b/source/login/loginDb.hpp @@ -5,6 +5,7 @@ #include #include "json.hpp" #include "utils.hpp" + namespace login { diff --git a/source/shadowrun/ShadowrunApi.cpp b/source/shadowrun/ShadowrunApi.cpp index d30c2ee..014c966 100644 --- a/source/shadowrun/ShadowrunApi.cpp +++ b/source/shadowrun/ShadowrunApi.cpp @@ -3,6 +3,7 @@ #include "ShadowrunApi.hpp" #include "ShadowrunDb.hpp" #include "login.hpp" +#include "magic_enum.hpp" #include using namespace std; diff --git a/source/shadowrun/ShadowrunApi.hpp b/source/shadowrun/ShadowrunApi.hpp index db8870c..acb1f75 100644 --- a/source/shadowrun/ShadowrunApi.hpp +++ b/source/shadowrun/ShadowrunApi.hpp @@ -1,7 +1,7 @@ #ifndef __SHADOWRUNAPI_H__ #define __SHADOWRUNAPI_H__ -#include "crow.h" +#include "crow/app.h" #include "crow/middlewares/cors.h" namespace shadowrun { diff --git a/source/shadowrun/ShadowrunDb.cpp b/source/shadowrun/ShadowrunDb.cpp index 7530bf3..1336679 100644 --- a/source/shadowrun/ShadowrunDb.cpp +++ b/source/shadowrun/ShadowrunDb.cpp @@ -1,6 +1,7 @@ #include "ShadowrunDb.hpp" #include #include "databasepool.h" +#include "magic_enum.hpp" #include "utils.hpp" #include "crow/logging.h" diff --git a/source/shadowrun/ShadowrunDb.hpp b/source/shadowrun/ShadowrunDb.hpp index e4d19bd..f40b972 100644 --- a/source/shadowrun/ShadowrunDb.hpp +++ b/source/shadowrun/ShadowrunDb.hpp @@ -7,8 +7,6 @@ #include #include "json.hpp" #include "utils.hpp" -#include "sqlite_orm.h" -#include "magic_enum.hpp" namespace shadowrun { enum class Type { diff --git a/source/utils.hpp b/source/utils.hpp index 50f37ee..fb7909f 100644 --- a/source/utils.hpp +++ b/source/utils.hpp @@ -7,7 +7,7 @@ #include #include #include "json.hpp" -#include "crow.h" +#include "crow/http_response.h" namespace utils { // Svelte genereated files