Commit f36bd086 authored by jan.koester's avatar jan.koester
Browse files

test

parent 3ad01300
Loading
Loading
Loading
Loading
+12 −7
Changes for src/blogi.cpp: 12 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -73,9 +73,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#define MAX_RETRIES 5

static std::string cookieDomain(const std::string &host) {
    if (host.empty()) return std::string();
    std::string h(host);
static std::string cookieDomain(libhttppp::HttpRequest &req) {
    std::string h;
    auto *fwd = req.getHeaderData("x-forwarded-host");
    if (fwd)
        h = fwd->at(0).getvalue();
    else
        h = req.getHost();
    if (h.empty()) return std::string();
    // Strip port if present
    auto colon = h.find(':');
    if (colon != std::string::npos) h = h.substr(0, colon);
@@ -421,7 +426,7 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest &curreq,const int tid,const
        libhttppp::HttpResponse curres;
        // Clear stale auth cookie when showing login form
        libhttppp::HttpCookie cookclr;
        cookclr.setcookie(curres,"authid","","",cookieDomain(curreq.getHost()).c_str(),0,"/");
        cookclr.setcookie(curres,"authid","","",cookieDomain(curreq).c_str(),0,"/");
        curres.setState(HTTP200);
        curres.setContentType("text/html");
        sendCompressed(curreq,curres,out.c_str(),out.length());
@@ -435,7 +440,7 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest &curreq,const int tid,const
        libhttppp::HttpResponse curres;
        libhttppp::HttpCookie authid;

        authid.setcookie(curres,"authid",sessid.c_str(),"",cookieDomain(curreq.getHost()).c_str(),(1000*60*60*1),"/",false,"1","Lax",false);
        authid.setcookie(curres,"authid",sessid.c_str(),"",cookieDomain(curreq).c_str(),(1000*60*60*1),"/",false,"1","Lax",false);

        curres.setState(HTTP307);
        curres.setHeaderData("location")->push_back(PlgArgs->config->getstartpage());
@@ -1230,7 +1235,7 @@ void blogi::Blogi::settingsApi(libhttppp::HttpRequest& curreq,const int tid,cons
        libhttppp::HttpResponse resp;
        // Clear stale auth cookie
        libhttppp::HttpCookie cookclr;
        cookclr.setcookie(resp,"authid","","",cookieDomain(curreq.getHost()).c_str(),-1,"/");
        cookclr.setcookie(resp,"authid","","",cookieDomain(curreq).c_str(),-1,"/");
        resp.setState(HTTP401);
        resp.setContentType("application/json");
        const char *err = "{\"success\":false,\"error\":\"not logged in\"}";
@@ -1995,7 +2000,7 @@ RETRY_REQUEST:
                        cban.setPermission(sessid,cururlform.key.c_str(),false);
                }

                cookie.setcookie(curres, "sessionid", sessid,"",cookieDomain(curreq.getHost()).c_str() ,(1000*60*60*1),"/",false,"1","Lax",false);
                cookie.setcookie(curres, "sessionid", sessid,"",cookieDomain(curreq).c_str() ,(1000*60*60*1),"/",false,"1","Lax",false);
                curres.setState(HTTP307);
                curres.setHeaderData("location")->push_back(curreq.getRequestURL());
                curres.setContentType("text/html");