Loading editor/src/webedit_server.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -91,6 +91,16 @@ std::string webedit::Server::getCookie(libhttppp::HttpRequest &curreq, return ""; } std::string webedit::Server::resolveAuthId(libhttppp::HttpRequest &curreq, const std::string &sessionid) { std::string authid = getCookie(curreq, "authid"); if (!authid.empty()) return authid; _session.getData(sessionid, "authid", authid); return authid; } void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, const int tid, ULONG_PTR args) { try { Loading Loading @@ -174,7 +184,7 @@ void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, // Check authentication for all other API routes if (url.find("/api/") == 0) { std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (authid.empty() || !isAuthenticated(authid)) { sendJsonResponse(curreq, HTTP401, "{\"error\":\"Not authenticated\"}", Loading @@ -192,7 +202,7 @@ void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, // Static files — login page is always accessible if (url == "/" || url == "/index.html") { // Check if authenticated; if not, serve login page std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (authid.empty() || !isAuthenticated(authid)) { url = "/login.html"; } Loading Loading @@ -523,7 +533,7 @@ void webedit::Server::handleLogin(libhttppp::HttpRequest &curreq, void webedit::Server::handleLogout(libhttppp::HttpRequest &curreq, const std::string &sessionid) { std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (!authid.empty()) { // Remove authdb session Loading Loading @@ -561,7 +571,7 @@ void webedit::Server::handleLogout(libhttppp::HttpRequest &curreq, void webedit::Server::handleAuthCheck(libhttppp::HttpRequest &curreq, const std::string &sessionid) { std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (!authid.empty() && isAuthenticated(authid)) { sendJsonResponse(curreq, HTTP200, Loading editor/src/webedit_server.h +1 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ namespace webedit { const std::string &newSessionId = ""); std::string getMimeType(const std::string &path); std::string getCookie(libhttppp::HttpRequest &curreq, const std::string &name); std::string resolveAuthId(libhttppp::HttpRequest &curreq, const std::string &sessionid); bool isAuthenticated(const std::string &authid); void ensureSessionFromAuthid(const std::string &authid, const std::string &sessionid); Loading Loading
editor/src/webedit_server.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -91,6 +91,16 @@ std::string webedit::Server::getCookie(libhttppp::HttpRequest &curreq, return ""; } std::string webedit::Server::resolveAuthId(libhttppp::HttpRequest &curreq, const std::string &sessionid) { std::string authid = getCookie(curreq, "authid"); if (!authid.empty()) return authid; _session.getData(sessionid, "authid", authid); return authid; } void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, const int tid, ULONG_PTR args) { try { Loading Loading @@ -174,7 +184,7 @@ void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, // Check authentication for all other API routes if (url.find("/api/") == 0) { std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (authid.empty() || !isAuthenticated(authid)) { sendJsonResponse(curreq, HTTP401, "{\"error\":\"Not authenticated\"}", Loading @@ -192,7 +202,7 @@ void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq, // Static files — login page is always accessible if (url == "/" || url == "/index.html") { // Check if authenticated; if not, serve login page std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (authid.empty() || !isAuthenticated(authid)) { url = "/login.html"; } Loading Loading @@ -523,7 +533,7 @@ void webedit::Server::handleLogin(libhttppp::HttpRequest &curreq, void webedit::Server::handleLogout(libhttppp::HttpRequest &curreq, const std::string &sessionid) { std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (!authid.empty()) { // Remove authdb session Loading Loading @@ -561,7 +571,7 @@ void webedit::Server::handleLogout(libhttppp::HttpRequest &curreq, void webedit::Server::handleAuthCheck(libhttppp::HttpRequest &curreq, const std::string &sessionid) { std::string authid = getCookie(curreq, "authid"); std::string authid = resolveAuthId(curreq, sessionid); if (!authid.empty() && isAuthenticated(authid)) { sendJsonResponse(curreq, HTTP200, Loading
editor/src/webedit_server.h +1 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ namespace webedit { const std::string &newSessionId = ""); std::string getMimeType(const std::string &path); std::string getCookie(libhttppp::HttpRequest &curreq, const std::string &name); std::string resolveAuthId(libhttppp::HttpRequest &curreq, const std::string &sessionid); bool isAuthenticated(const std::string &authid); void ensureSessionFromAuthid(const std::string &authid, const std::string &sessionid); Loading