Loading src/edit.cpp +19 −10 Changes for src/edit.cpp: 19 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -61,9 +61,17 @@ blogi::webedit::WebEditor::WebEditor(PluginArgs &plgargs) : Args (plgargs){ #define GPO_EDITOR_IMPORTEXPORT "f46a4fd3-a69a-4fb4-a908-c5890a244386" void blogi::webedit::WebEditor::registerEditorGPOs(){ auto reg = [&](const char *gpoid, const char *name, const char *desc){ if(Args.config->getAuthSourceCount() < 1) return; struct GpoDef { const char *id; const char *name; const char *desc; }; GpoDef gpos[] = { {GPO_EDITOR_PUBLISH, "Blogi: Publish Content", "Controls access to publishing content from the editor"}, {GPO_EDITOR_SHARE, "Blogi: Share Posts", "Controls access to sharing posts to social networks"}, {GPO_EDITOR_TEMPLATES, "Blogi: Manage Templates", "Controls access to saving and loading editor templates"}, {GPO_EDITOR_IMPORTEXPORT, "Blogi: Import/Export", "Controls access to importing and exporting editor content"}, }; for(size_t i = 0; i < Args.config->getAuthSourceCount(); ++i){ try { const AuthSource &src = Args.config->getAuthSource(i); Loading @@ -73,21 +81,22 @@ void blogi::webedit::WebEditor::registerEditorGPOs(){ authcon.setClientSecret(src.clientSecret); authdb::client::Client clt(authcon); if(clt.ClientAuth()){ uuid::uuid gid(gpoid); for(auto &g : gpos){ try { uuid::uuid gid(g.id); if(!clt.GPOexits(gid)) clt.GPOadd(gid, name, desc, true, {}); clt.GPOadd(gid, g.name, g.desc, true, {}); } catch(const std::exception &e) { std::cerr << "Editor GPO registration failed for " << g.name << ": " << e.what() << std::endl; } } } } catch(const std::exception &e) { std::cerr << "Editor GPO registration failed for " << name << ": " << e.what() << std::endl; std::cerr << "Editor GPO auth failed: " << e.what() << std::endl; } catch(...) { std::cerr << "Editor GPO registration failed for " << name << std::endl; std::cerr << "Editor GPO auth failed" << std::endl; } } }; reg(GPO_EDITOR_PUBLISH, "Blogi: Publish Content", "Controls access to publishing content from the editor"); reg(GPO_EDITOR_SHARE, "Blogi: Share Posts", "Controls access to sharing posts to social networks"); reg(GPO_EDITOR_TEMPLATES, "Blogi: Manage Templates", "Controls access to saving and loading editor templates"); reg(GPO_EDITOR_IMPORTEXPORT, "Blogi: Import/Export", "Controls access to importing and exporting editor content"); } bool blogi::webedit::WebEditor::checkEditorGPO(json_object *request, const char *gpoid){ Loading Loading
src/edit.cpp +19 −10 Changes for src/edit.cpp: 19 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -61,9 +61,17 @@ blogi::webedit::WebEditor::WebEditor(PluginArgs &plgargs) : Args (plgargs){ #define GPO_EDITOR_IMPORTEXPORT "f46a4fd3-a69a-4fb4-a908-c5890a244386" void blogi::webedit::WebEditor::registerEditorGPOs(){ auto reg = [&](const char *gpoid, const char *name, const char *desc){ if(Args.config->getAuthSourceCount() < 1) return; struct GpoDef { const char *id; const char *name; const char *desc; }; GpoDef gpos[] = { {GPO_EDITOR_PUBLISH, "Blogi: Publish Content", "Controls access to publishing content from the editor"}, {GPO_EDITOR_SHARE, "Blogi: Share Posts", "Controls access to sharing posts to social networks"}, {GPO_EDITOR_TEMPLATES, "Blogi: Manage Templates", "Controls access to saving and loading editor templates"}, {GPO_EDITOR_IMPORTEXPORT, "Blogi: Import/Export", "Controls access to importing and exporting editor content"}, }; for(size_t i = 0; i < Args.config->getAuthSourceCount(); ++i){ try { const AuthSource &src = Args.config->getAuthSource(i); Loading @@ -73,21 +81,22 @@ void blogi::webedit::WebEditor::registerEditorGPOs(){ authcon.setClientSecret(src.clientSecret); authdb::client::Client clt(authcon); if(clt.ClientAuth()){ uuid::uuid gid(gpoid); for(auto &g : gpos){ try { uuid::uuid gid(g.id); if(!clt.GPOexits(gid)) clt.GPOadd(gid, name, desc, true, {}); clt.GPOadd(gid, g.name, g.desc, true, {}); } catch(const std::exception &e) { std::cerr << "Editor GPO registration failed for " << g.name << ": " << e.what() << std::endl; } } } } catch(const std::exception &e) { std::cerr << "Editor GPO registration failed for " << name << ": " << e.what() << std::endl; std::cerr << "Editor GPO auth failed: " << e.what() << std::endl; } catch(...) { std::cerr << "Editor GPO registration failed for " << name << std::endl; std::cerr << "Editor GPO auth failed" << std::endl; } } }; reg(GPO_EDITOR_PUBLISH, "Blogi: Publish Content", "Controls access to publishing content from the editor"); reg(GPO_EDITOR_SHARE, "Blogi: Share Posts", "Controls access to sharing posts to social networks"); reg(GPO_EDITOR_TEMPLATES, "Blogi: Manage Templates", "Controls access to saving and loading editor templates"); reg(GPO_EDITOR_IMPORTEXPORT, "Blogi: Import/Export", "Controls access to importing and exporting editor content"); } bool blogi::webedit::WebEditor::checkEditorGPO(json_object *request, const char *gpoid){ Loading