Loading src/admin.cpp +84 −84 Changes for src/admin.cpp: 84 added lines, 84 removed lines. Original line number Diff line number Diff line Loading @@ -2341,90 +2341,90 @@ namespace authdb { uuid ssid; // try{ // // cookie.parse(curreq); // // for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ // if(strcmp(cur->getKey(),"authdbid")==0){ // if(ssid.parse(cur->getValue())==0){ // sdat=AuthSession.getSession(ssid); // } // break; // } // } // // if(curreq->getRequestURL().compare("/settings/logout")==0){ // AuthSession.remSession(ssid); // libhttppp::HttpResponse rep; // rep.setState(HTTP303); // rep.setVersion(HTTPVERSION(1.1)); // rep.setHeaderData("Location")->push_back("/settings/index"); // rep.setContentType("text/html"); // rep.send(curreq,nullptr,0); // return; // } // // if(!sdat){ // throw AuthBackendError("No Session found!"); // } // }catch(...){ // try { // login(curreq,tid,args); // return; // }catch(AuthBackendError &el){ // 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 *loginel=index.getElementbyID("login"); // // Domain domain; // // size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); // // while(rd<end){ // std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); // // cur->type=EmptyData; // // _AdminBackend.setPos(rd); // _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); // // rd=_AdminBackend.getPos()+cur->datasize; // // if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ // class DomainData ddat(cur->ruid); // // try { // size_t dpos=sizeof(authdb::AuthHeader); // domain.info(_AdminBackend,ddat,dpos); // // *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" // << ddat.getDomainName() // << "</option>"; // // domel->appendChild(dform->parse()); // dform->clear(); // }catch(AuthBackendError &e){ // std::cerr << e.what() << std::endl; // } // } // } // // if(loginel && el.what()){ // libhtmlpp::HtmlString errmsg; // errmsg << "<span>" << el.what() << "</span>"; // loginel->appendChild(errmsg.parse()); // } // // libhtmlpp::print(&index,*out,true); // libhttppp::HttpResponse rep; // rep.setContentType("text/html"); // rep.send(curreq,out->c_str(),out->size()); // return; // } // } try{ cookie.parse(curreq); for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ if(strcmp(cur->getKey(),"authdbid")==0){ if(ssid.parse(cur->getValue())==0){ sdat=AuthSession.getSession(ssid); } break; } } if(curreq->getRequestURL().compare("/settings/logout")==0){ AuthSession.remSession(ssid); libhttppp::HttpResponse rep; rep.setState(HTTP303); rep.setVersion(HTTPVERSION(1.1)); rep.setHeaderData("Location")->push_back("/settings/index"); rep.setContentType("text/html"); rep.send(curreq,nullptr,0); return; } if(!sdat){ throw AuthBackendError("No Session found!"); } }catch(...){ try { login(curreq,tid,args); return; }catch(AuthBackendError &el){ 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 *loginel=index.getElementbyID("login"); Domain domain; size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); while(rd<end){ std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); cur->type=EmptyData; _AdminBackend.setPos(rd); _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); rd=_AdminBackend.getPos()+cur->datasize; if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ class DomainData ddat(cur->ruid); try { size_t dpos=sizeof(authdb::AuthHeader); domain.info(_AdminBackend,ddat,dpos); *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" << ddat.getDomainName() << "</option>"; domel->appendChild(dform->parse()); dform->clear(); }catch(AuthBackendError &e){ std::cerr << e.what() << std::endl; } } } if(loginel && el.what()){ libhtmlpp::HtmlString errmsg; errmsg << "<span>" << el.what() << "</span>"; loginel->appendChild(errmsg.parse()); } libhtmlpp::print(&index,*out,true); libhttppp::HttpResponse rep; rep.setContentType("text/html"); rep.send(curreq,out->c_str(),out->size()); return; } } char domain[255]={},url[255]={}; Loading Loading
src/admin.cpp +84 −84 Changes for src/admin.cpp: 84 added lines, 84 removed lines. Original line number Diff line number Diff line Loading @@ -2341,90 +2341,90 @@ namespace authdb { uuid ssid; // try{ // // cookie.parse(curreq); // // for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ // if(strcmp(cur->getKey(),"authdbid")==0){ // if(ssid.parse(cur->getValue())==0){ // sdat=AuthSession.getSession(ssid); // } // break; // } // } // // if(curreq->getRequestURL().compare("/settings/logout")==0){ // AuthSession.remSession(ssid); // libhttppp::HttpResponse rep; // rep.setState(HTTP303); // rep.setVersion(HTTPVERSION(1.1)); // rep.setHeaderData("Location")->push_back("/settings/index"); // rep.setContentType("text/html"); // rep.send(curreq,nullptr,0); // return; // } // // if(!sdat){ // throw AuthBackendError("No Session found!"); // } // }catch(...){ // try { // login(curreq,tid,args); // return; // }catch(AuthBackendError &el){ // 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 *loginel=index.getElementbyID("login"); // // Domain domain; // // size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); // // while(rd<end){ // std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); // // cur->type=EmptyData; // // _AdminBackend.setPos(rd); // _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); // // rd=_AdminBackend.getPos()+cur->datasize; // // if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ // class DomainData ddat(cur->ruid); // // try { // size_t dpos=sizeof(authdb::AuthHeader); // domain.info(_AdminBackend,ddat,dpos); // // *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" // << ddat.getDomainName() // << "</option>"; // // domel->appendChild(dform->parse()); // dform->clear(); // }catch(AuthBackendError &e){ // std::cerr << e.what() << std::endl; // } // } // } // // if(loginel && el.what()){ // libhtmlpp::HtmlString errmsg; // errmsg << "<span>" << el.what() << "</span>"; // loginel->appendChild(errmsg.parse()); // } // // libhtmlpp::print(&index,*out,true); // libhttppp::HttpResponse rep; // rep.setContentType("text/html"); // rep.send(curreq,out->c_str(),out->size()); // return; // } // } try{ cookie.parse(curreq); for(libhttppp::HttpCookie::CookieData *cur=cookie.getfirstCookieData(); cur; cur=cur->nextCookieData()){ if(strcmp(cur->getKey(),"authdbid")==0){ if(ssid.parse(cur->getValue())==0){ sdat=AuthSession.getSession(ssid); } break; } } if(curreq->getRequestURL().compare("/settings/logout")==0){ AuthSession.remSession(ssid); libhttppp::HttpResponse rep; rep.setState(HTTP303); rep.setVersion(HTTPVERSION(1.1)); rep.setHeaderData("Location")->push_back("/settings/index"); rep.setContentType("text/html"); rep.send(curreq,nullptr,0); return; } if(!sdat){ throw AuthBackendError("No Session found!"); } }catch(...){ try { login(curreq,tid,args); return; }catch(AuthBackendError &el){ 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 *loginel=index.getElementbyID("login"); Domain domain; size_t rd=sizeof(authdb::AuthHeader),end=_AdminBackend.end(); while(rd<end){ std::shared_ptr <authdb::AuthData::Record> cur=std::make_shared<authdb::AuthData::Record>(); cur->type=EmptyData; _AdminBackend.setPos(rd); _AdminBackend.read((unsigned char*)cur.get(),sizeof(AuthData::Record)); rd=_AdminBackend.getPos()+cur->datasize; if(cur->type == DataType::DomainData && strcmp(cur->fieldname,"domainname")==0){ class DomainData ddat(cur->ruid); try { size_t dpos=sizeof(authdb::AuthHeader); domain.info(_AdminBackend,ddat,dpos); *dform << "<option value=\"" << uuid(cur->ruid).c_str() << "\" >" << ddat.getDomainName() << "</option>"; domel->appendChild(dform->parse()); dform->clear(); }catch(AuthBackendError &e){ std::cerr << e.what() << std::endl; } } } if(loginel && el.what()){ libhtmlpp::HtmlString errmsg; errmsg << "<span>" << el.what() << "</span>"; loginel->appendChild(errmsg.parse()); } libhtmlpp::print(&index,*out,true); libhttppp::HttpResponse rep; rep.setContentType("text/html"); rep.send(curreq,out->c_str(),out->size()); return; } } char domain[255]={},url[255]={}; Loading