Loading src/admin.cpp +63 −0 Changes for src/admin.cpp: 63 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2298,6 +2298,8 @@ namespace authdb { libhtmlpp::HtmlString clistdata; clistdata << "<li>" << cruid << ": " << cdat.getName() << "<a class=\"button\" href=\"/settings/" << cdid << "/" << "editclient/" << cruid << "\">Edit</a>" << "<a class=\"button\" href=\"/settings/" << cdid << "/" << "removeclient/" << cruid << "\">Delete</a>" << "</li>"; Loading Loading @@ -2365,6 +2367,65 @@ namespace authdb { rep.send(curreq,nullptr,0); } void editClient(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){ libhtmlpp::HtmlElement index=_IndexElement; char cdid[255],cclid[255]; uuid_t did,clid; if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/editclient/%s",cdid,cclid)<0){ throw AuthBackendError("editclient: wrong url!"); } DomainBackend dbackend(_AdminBackend); AuthBackend *backend=nullptr; if(strcmp(cdid,"admin") == 0 ){ backend=&_AdminBackend; }else if(uuid_parse(cdid,did) == 0 ){ backend=dbackend.data(did); }else{ throw AuthBackendError("editclient: could not parse domain uuid!"); } if(uuid_parse(cclid,clid)==0) throw AuthBackendError("editclient: could not parse client uuid!"); class ClientData cldat(clid); class Client clt; size_t pos=sizeof(AuthHeader); clt.info(*backend,cldat,pos); libhtmlpp::HtmlString cleform,out; cleform << "<form method=\"post\" >" << "<label for=\"clientname\" >Clientname:</label>" << "<input name=\"clientname\" type=\"text\" value=\""<< cldat.getName() <<"\">" << "<label for=\"clientkey\" >Clientkey:</label>" << "<input name=\"clientkey\" type=\"password\" value=\""<< cldat.getKey() <<"\">" << "<input type=\"submit\" value=\"Save\">" <<"</form>"; libhtmlpp::HtmlElement *content=index.getElementbyID("content"); if(content){ content->appendChild((libhtmlpp::Element*)&cleform); } libhtmlpp::print(&index,out,false); libhttppp::HttpResponse rep; rep.setState(HTTP200); rep.setVersion(HTTPVERSION(1.1)); rep.setContentType("text/html"); rep.send(curreq,out.c_str(),out.size()); } void SettingsController(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){ libhttppp::HttpCookie cookie; Loading Loading @@ -2504,6 +2565,8 @@ namespace authdb { createClient(curreq,tid,args); }else if(strncmp("removeclient",url,12)==0){ removeClient(curreq,tid,args); }else if(strncmp("editclient",url,11)==0){ editClient(curreq,tid,args); }else{ URLNOTFOUND: uuid_t did; Loading Loading
src/admin.cpp +63 −0 Changes for src/admin.cpp: 63 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2298,6 +2298,8 @@ namespace authdb { libhtmlpp::HtmlString clistdata; clistdata << "<li>" << cruid << ": " << cdat.getName() << "<a class=\"button\" href=\"/settings/" << cdid << "/" << "editclient/" << cruid << "\">Edit</a>" << "<a class=\"button\" href=\"/settings/" << cdid << "/" << "removeclient/" << cruid << "\">Delete</a>" << "</li>"; Loading Loading @@ -2365,6 +2367,65 @@ namespace authdb { rep.send(curreq,nullptr,0); } void editClient(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){ libhtmlpp::HtmlElement index=_IndexElement; char cdid[255],cclid[255]; uuid_t did,clid; if(sscanf(curreq->getRequestURL(),"/settings/%[^/]/editclient/%s",cdid,cclid)<0){ throw AuthBackendError("editclient: wrong url!"); } DomainBackend dbackend(_AdminBackend); AuthBackend *backend=nullptr; if(strcmp(cdid,"admin") == 0 ){ backend=&_AdminBackend; }else if(uuid_parse(cdid,did) == 0 ){ backend=dbackend.data(did); }else{ throw AuthBackendError("editclient: could not parse domain uuid!"); } if(uuid_parse(cclid,clid)==0) throw AuthBackendError("editclient: could not parse client uuid!"); class ClientData cldat(clid); class Client clt; size_t pos=sizeof(AuthHeader); clt.info(*backend,cldat,pos); libhtmlpp::HtmlString cleform,out; cleform << "<form method=\"post\" >" << "<label for=\"clientname\" >Clientname:</label>" << "<input name=\"clientname\" type=\"text\" value=\""<< cldat.getName() <<"\">" << "<label for=\"clientkey\" >Clientkey:</label>" << "<input name=\"clientkey\" type=\"password\" value=\""<< cldat.getKey() <<"\">" << "<input type=\"submit\" value=\"Save\">" <<"</form>"; libhtmlpp::HtmlElement *content=index.getElementbyID("content"); if(content){ content->appendChild((libhtmlpp::Element*)&cleform); } libhtmlpp::print(&index,out,false); libhttppp::HttpResponse rep; rep.setState(HTTP200); rep.setVersion(HTTPVERSION(1.1)); rep.setContentType("text/html"); rep.send(curreq,out.c_str(),out.size()); } void SettingsController(libhttppp::HttpRequest *curreq, const int tid, ULONG_PTR args){ libhttppp::HttpCookie cookie; Loading Loading @@ -2504,6 +2565,8 @@ namespace authdb { createClient(curreq,tid,args); }else if(strncmp("removeclient",url,12)==0){ removeClient(curreq,tid,args); }else if(strncmp("editclient",url,11)==0){ editClient(curreq,tid,args); }else{ URLNOTFOUND: uuid_t did; Loading