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

test

parent c4bea2c4
Loading
Loading
Loading
Loading
+15 −1
Changes for editor/html/js/api.js: 15 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -313,7 +313,21 @@ var EditorApi = (function() {
        },

        connectToConnection: function(id) {
            return request('POST', '/api/connection/connect/' + id, {});
            return request('POST', '/api/connection/connect/' + id, {}).then(function(resp) {
                if (resp && resp.blogUrl && resp.authid) {
                    var iframe = document.createElement('iframe');
                    var loginUrl = resp.blogUrl;
                    if (loginUrl.slice(-1) !== '/') loginUrl += '/';
                    loginUrl += 'login?authid=' + encodeURIComponent(resp.authid);
                    iframe.src = loginUrl;
                    iframe.style.display = 'none';
                    document.body.appendChild(iframe);
                    setTimeout(function() { 
                        if (iframe.parentNode) iframe.parentNode.removeChild(iframe); 
                    }, 10000);
                }
                return resp;
            });
        },

        publishToConnection: function(id, target, params) {
+2 −0
Changes for editor/src/webedit_api.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3122,6 +3122,8 @@ void webedit::Api::handleConnectToConnection(libhttppp::HttpRequest &curreq,
        json_object_object_add(resp, "status", json_object_new_string("ok"));
        json_object_object_add(resp, "connected", json_object_new_boolean(1));
        json_object_object_add(resp, "targets", targetsResult);
        json_object_object_add(resp, "blogUrl", json_object_new_string(blogUrl.c_str()));
        json_object_object_add(resp, "authid", json_object_new_string(authid.c_str()));
        sendJson(curreq, resp);
        json_object_put(resp);

+13 −2
Changes for src/blogi.cpp: 13 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -883,19 +883,23 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest &curreq,const int tid,const

    std::string username;
    std::string password;

    std::string authToken;

    for (const auto &cururlform : curform.urlData()) {
        if (cururlform.key== "username") {
            username = cururlform.value;
        }else if (cururlform.key== "password") {
            password = cururlform.value;
        }else if (cururlform.key== "authid") {
            authToken = cururlform.value;
        }
    }

    libhtmlpp::HtmlString out;

    if (username.empty() || password.empty()) {
    if (!authToken.empty() && PlgArgs->auth->isLoggedIn(tid, uuid::uuid(authToken))) {
        // Fast-path automatic login using existing authid
    } else if (username.empty() || password.empty()) {
        std::string _lang = blogi::getLang(*PlgArgs->database[tid]);
        libhtmlpp::HtmlString condat;
        condat << "<div id=\"content\">"
@@ -947,7 +951,14 @@ void blogi::Blogi::loginPage(libhttppp::HttpRequest &curreq,const int tid,const
    }

    uuid::uuid sessid;
    if (!authToken.empty() && PlgArgs->auth->isLoggedIn(tid, uuid::uuid(authToken))) {
        sessid = uuid::uuid(authToken);
        Session sess(*PlgArgs->database[tid]);
        sess.delSessionData(loginSessionId, "authid");
        sess.addSessionData(loginSessionId, "authid", authToken.c_str());
    } else {
        PlgArgs->auth->login(tid,username.c_str(),password.c_str(),sessid,loginSessionId,ctx.domainName);
    }

    if(!sessid.empty()){
        libhttppp::HttpResponse curres;