Commit 769f520a authored by jan.koester's avatar jan.koester
Browse files

client form finished

parent a0a6823c
Loading
Loading
Loading
Loading
Loading
+59 −0
Changes for src/admin.cpp: 59 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2129,8 +2129,66 @@ namespace authdb {
                throw AuthBackendError("listUsers: could not parse uuid!");
            }

            libhttppp::HttpForm form;
            form.parse(curreq);

            if(form.UrlFormData.getFormData()){
                for(libhttppp::HttpForm::UrlcodedForm::Data *curdat=form.UrlFormData.getFormData(); curdat;
                    curdat=curdat->nextData()
                ){

                }
                libhttppp::HttpResponse rep;
                rep.setState(HTTP303);
                rep.setVersion(HTTPVERSION(1.1));
                std::string rurl="/settings/"; rurl +=cdid; rurl+="/listclients";
                rep.setHeaderData("Location")->push_back(rurl.c_str());
                rep.setContentType("text/html");
                rep.send(curreq,nullptr,0);
                return;
            }

            libhtmlpp::HtmlString sendat;

            libhtmlpp::HtmlElement hform("form"),clist("ul");

            hform.setAttribute("method","post");
            hform.insertChild(clist);

            libhtmlpp::HtmlElement name("input"),lname("label"),namel("li");
            libhtmlpp::HtmlElement secret("input"),lsecret("label"),secretl("li");

            libhtmlpp::HtmlElement submit("input"),submitl("li");
            submit.setAttribute("type","submit");
            submit.setAttribute("value","create");
            submitl.insertChild(submit);

            lname.insertChild(libhtmlpp::TextElement("Client name:"));
            name.setAttribute("type","text");
            name.setAttribute("name","clientname");

            lsecret.insertChild(libhtmlpp::TextElement("Client secret:"));
            secret.setAttribute("type","text");
            secret.setAttribute("name","secret");

            namel.appendChild(lname);
            namel.appendChild(name);

            secretl.appendChild(lsecret);
            secretl.appendChild(secret);

            clist.appendChild(namel);
            clist.appendChild(secretl);
            clist.appendChild(submitl);

            hform.insertChild(clist);

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

            if(content){
                content->appendChild(hform);
            }

            libhtmlpp::print((libhtmlpp::Element*)&index,sendat,false);

            libhttppp::HttpResponse rep;
@@ -2192,6 +2250,7 @@ namespace authdb {
            libhtmlpp::HtmlElement *content=index.getElementbyID("content");

            if(content){
                content->appendChild(domel);
                content->appendChild(headline);
                content->appendChild(toolbar);
            }