From 6d3673a8584585d300a36e1af813ff631ab6c904 Mon Sep 17 00:00:00 2001 From: Ryan Blenis Date: Mon, 11 Nov 2019 09:46:38 -0500 Subject: [PATCH] Add plugin "type" to plugins (permission sets coming soon) --- db.js | 4 ++-- meshuser.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db.js b/db.js index d0f8adad..298b30eb 100644 --- a/db.js +++ b/db.js @@ -753,10 +753,10 @@ module.exports.CreateDB = function (parent, func) { } // Add a plugin - obj.addPlugin = function (plugin, func) { obj.pluginsfile.insertOne(plugin, func); }; + obj.addPlugin = function (plugin, func) { plugin.type = "plugin"; obj.pluginsfile.insertOne(plugin, func); }; // Get all plugins - obj.getPlugins = function (func) { obj.pluginsfile.find().sort({ name: 1 }).toArray(func); }; + obj.getPlugins = function (func) { obj.pluginsfile.find({"type": "plugin"}).project({"type": 0}).sort({ name: 1 }).toArray(func); }; // Get plugin obj.getPlugin = function (id, func) { id = require('mongodb').ObjectID(id); obj.pluginsfile.find({ _id: id }).sort({ name: 1 }).toArray(func); }; diff --git a/meshuser.js b/meshuser.js index 390586e3..2aed47ef 100644 --- a/meshuser.js +++ b/meshuser.js @@ -3113,7 +3113,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use break; } case 'plugins': { - // @Ylianst - Do we need a new permission set here? + // Since plugin actions generally require a server restart, use the Full admin permission if ((user.siteadmin & 0xFFFFFFFF) == 0 || parent.parent.pluginHandler == null) break; // must be full admin with plugins enabled parent.db.getPlugins(function(err, docs) { try { ws.send(JSON.stringify({ action: 'updatePluginList', list: docs, result: err })); } catch (ex) { }