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

test

parent 00d13afc
Loading
Loading
Loading
Loading
Loading
+33 −28
Changes for src/admin.cpp: 33 added lines, 28 removed lines.
Original line number Diff line number Diff line
@@ -47,14 +47,18 @@ namespace authdb {
    class AdminController {
    public:
        AdminController(authdb::AuthBackend &backend,netplus::socket *ssock) : _AdminBackend(backend) {
            _Indexpage.loadFile(_IndexElement,GETDATA(index.html));
            _Loginpage.loadFile(_LoginElement,GETDATA(login.html));
            _IndexElement=std::make_shared<libhtmlpp::HtmlElement>();
            _Indexpage=std::make_shared<libhtmlpp::HtmlPage>();
            _Indexpage->loadFile(*_IndexElement,GETDATA(index.html));
            _LoginElement=std::make_shared<libhtmlpp::HtmlElement>();
            _Loginpage=std::make_shared<libhtmlpp::HtmlPage>();
            _Loginpage->loadFile(*_LoginElement,GETDATA(login.html));
        };

        void listUsers(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            libhtmlpp::HtmlString userlist,out,ddat;

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;

            libhtmlpp::HtmlElement *content=root.getElementbyID("content"),*domel=nullptr;

@@ -312,7 +316,7 @@ namespace authdb {
                  << "</table>"
                  << "</form";

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            content->insertChild(form.parse());
@@ -544,7 +548,7 @@ namespace authdb {
                  << "</table>"
                  << "</form";

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            content->insertChild(form.parse());
@@ -626,7 +630,7 @@ namespace authdb {

            libhtmlpp::HtmlString list,out;

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            Domain domain;
@@ -784,7 +788,7 @@ namespace authdb {

            libhtmlpp::HtmlString form,out;

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            form  << "<form method=\"post\" enctype=\"multipart/form-data\">"
@@ -837,7 +841,7 @@ namespace authdb {
        void listGroups(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            libhtmlpp::HtmlString grouplist,out,ddat;

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;

            libhtmlpp::HtmlElement *content=root.getElementbyID("content"),*domel=nullptr;

@@ -924,7 +928,7 @@ namespace authdb {
        void createGroup(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            libhtmlpp::HtmlString form,out;

            libhtmlpp::HtmlElement root=_IndexElement,*content=root.getElementbyID("content");
            libhtmlpp::HtmlElement root=*_IndexElement,*content=root.getElementbyID("content");

            char cdid[255];
            uuid_t did;
@@ -1349,7 +1353,7 @@ namespace authdb {
                  << "</table>"
                  << "</form>";

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            content->insertChild(form.parse());
@@ -1363,7 +1367,7 @@ namespace authdb {
        }

        void listSessions(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content"),*domel=nullptr;

            libhtmlpp::HtmlString out,ddat;
@@ -1650,7 +1654,7 @@ namespace authdb {
                  << "</form>"
                  << "</table>";

            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            content->insertChild(form.parse());
@@ -1853,7 +1857,7 @@ namespace authdb {
            }


            libhtmlpp::HtmlElement root=_IndexElement;
            libhtmlpp::HtmlElement root=*_IndexElement;
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            if(formel)
@@ -1896,7 +1900,7 @@ namespace authdb {



            libhtmlpp::HtmlElement root=_IndexElement,domel("table");
            libhtmlpp::HtmlElement root=*_IndexElement,domel("table");
            libhtmlpp::HtmlElement *content=root.getElementbyID("content");

            libhtmlpp::HtmlString list,out,ddat;
@@ -2112,7 +2116,7 @@ namespace authdb {
        }

        void createClient(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            libhtmlpp::HtmlElement index=_IndexElement;
            libhtmlpp::HtmlElement index=*_IndexElement;

            char cdid[255];
            uuid_t did;
@@ -2253,7 +2257,7 @@ namespace authdb {
            }


            libhtmlpp::HtmlElement index=_IndexElement;
            libhtmlpp::HtmlElement index=*_IndexElement;

            libhtmlpp::HtmlElement headline("span"),table("table"),toolbar("ul");

@@ -2371,7 +2375,7 @@ namespace authdb {
        }

        void editClient(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){
            libhtmlpp::HtmlElement index=_IndexElement;
            libhtmlpp::HtmlElement index=*_IndexElement;

            char cdid[255],cclid[255];
            uuid_t did,clid;
@@ -2502,9 +2506,10 @@ namespace authdb {
                    login(curreq,tid,args);
                    return;
                }catch(...){
                    libhtmlpp::HtmlString out,dform;
                    std::shared_ptr<libhtmlpp::HtmlString> out=std::make_shared<libhtmlpp::HtmlString>(),
                                                                                dform=std::make_shared<libhtmlpp::HtmlString>();

                    libhtmlpp::HtmlElement index=_LoginElement,*domel=index.getElementbyID("domain");
                    libhtmlpp::HtmlElement index=*_LoginElement,*domel=index.getElementbyID("domain");
                    Domain domain;

                    size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end();
@@ -2529,22 +2534,22 @@ namespace authdb {
                                char crdid[255];
                                uuid_unparse(cur.uuid,crdid);

                                dform << "<option value=\"" << crdid << "\" >"
                                *dform << "<option value=\"" << crdid << "\" >"
                                << ddat.getDomainName()
                                << "</option>";

                                domel->appendChild(dform.parse());
                                dform.clear();
                                domel->appendChild(dform->parse());
                                dform->clear();
                            }catch(AuthBackendError &e){
                                std::cerr << e.what() << std::endl;
                            }
                        }
                    }

                    libhtmlpp::print(&index,out,true);
                    libhtmlpp::print(&index,*out,true);
                    libhttppp::HttpResponse rep;
                    rep.setContentType("text/html");
                    rep.send(curreq,out.c_str(),out.size());
                    rep.send(curreq,out->c_str(),out->size());
                    return;
                }
            }
@@ -2624,10 +2629,10 @@ URLNOTFOUND:
        }
    private:
        authdb::AuthBackend     _AdminBackend;
        libhtmlpp::HtmlElement  _IndexElement;
        libhtmlpp::HtmlElement  _LoginElement;
        libhtmlpp::HtmlPage       _Indexpage;
        libhtmlpp::HtmlPage       _Loginpage;
        std::shared_ptr<libhtmlpp::HtmlElement>  _IndexElement;
        std::shared_ptr<libhtmlpp::HtmlElement>  _LoginElement;
        std::shared_ptr<libhtmlpp::HtmlPage>       _Indexpage;
        std::shared_ptr<libhtmlpp::HtmlPage>       _Loginpage;
    };

    AdminInterface::AdminInterface(AuthBackend &bck,netplus::socket *ssock) : _bck(bck) {