updated include to be more scoped
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "json.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace AppSettings {
|
||||
|
||||
static constexpr char settingsFile[] = "assets/settings.json";
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
#include "login.hpp"
|
||||
#include "crow/http_response.h"
|
||||
#include "databasepool.h"
|
||||
#include "SessionHandler.hpp"
|
||||
#include <optional>
|
||||
|
||||
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<std::string> loginUser(const std::string& username, const std::string& password)
|
||||
{
|
||||
auto user = getVerifiedUser(username, password);
|
||||
if (user) {
|
||||
return sessionHandler.createSession(user->id);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<crow::response> isLoggedIn(const crow::request& req) {
|
||||
std::string sessionId = getSessionId(req);
|
||||
if (sessionId.empty())
|
||||
@@ -36,15 +43,6 @@ std::optional<crow::response> isLoggedIn(const crow::request& req) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::optional<std::string> 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<crow::CORSHandler>& app){
|
||||
|
||||
createUser("lukas", "Trollar4928");
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <crow.h>
|
||||
#include <crow/http_response.h>
|
||||
#include <crow/app.h>
|
||||
#include "crow/middlewares/cors.h"
|
||||
|
||||
namespace login {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <vector>
|
||||
#include "json.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace login
|
||||
{
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "ShadowrunApi.hpp"
|
||||
#include "ShadowrunDb.hpp"
|
||||
#include "login.hpp"
|
||||
#include "magic_enum.hpp"
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __SHADOWRUNAPI_H__
|
||||
#define __SHADOWRUNAPI_H__
|
||||
|
||||
#include "crow.h"
|
||||
#include "crow/app.h"
|
||||
#include "crow/middlewares/cors.h"
|
||||
|
||||
namespace shadowrun {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "ShadowrunDb.hpp"
|
||||
#include <optional>
|
||||
#include "databasepool.h"
|
||||
#include "magic_enum.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "crow/logging.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include <optional>
|
||||
#include "json.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "sqlite_orm.h"
|
||||
#include "magic_enum.hpp"
|
||||
|
||||
namespace shadowrun {
|
||||
enum class Type {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <filesystem>
|
||||
#include <expected>
|
||||
#include "json.hpp"
|
||||
#include "crow.h"
|
||||
#include "crow/http_response.h"
|
||||
|
||||
namespace utils {
|
||||
// Svelte genereated files
|
||||
|
||||
Reference in New Issue
Block a user