Commit 9c21c78f authored by jan.koester's avatar jan.koester
Browse files

edit client gui polished

parent d1151018
Loading
Loading
Loading
Loading
Loading
+35 −1
Changes for src/admin.cpp: 35 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2393,13 +2393,47 @@ namespace authdb {
                 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);

            libhttppp::HttpForm cleformd;

            cleformd.parse(curreq);

            if(cleformd.UrlFormData.getFormData()){
                std::string key,keyhash;
                for(libhttppp::HttpForm::UrlcodedForm::Data *curdat=cleformd.UrlFormData.getFormData(); curdat;
                    curdat=curdat->nextData()){

                    if(strcmp("clientname",curdat->getKey())==0 )
                        cldat.setName(curdat->getValue());
                    else if (strcmp("clientkey",curdat->getKey())==0 && curdat->getValue() )
                        key=curdat->getValue();
                }

                if(!key.empty()){
                    sha512 hash;
                    hash.hash(key,keyhash);
                    cldat.setKey(keyhash.c_str());
                }

                clt.remove(*backend,clid);
                clt.create(*backend,&cldat);

                libhttppp::HttpResponse rep;
                rep.setState(HTTP307);
                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 cleform,out;

            cleform << "<form method=\"post\" >"